﻿@using Zocono.WCS.Admin.Models.User
@model UserModel

@{
    Layout = null;
}


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>1楼监控界面</title>
    <script src="~/js/signalr/dist/browser/signalr.js">
        const { signalR } = require("../../wwwroot/js/signalr/dist/browser/signalr");
    </script>
    <link rel="stylesheet" type="text/css" href="~/css/floor1/floor11.css">
    <link rel="stylesheet" type="text/css" href="~/css/floor1/index.css">
    <link rel="stylesheet" type="text/css" href="~/css/bootstrap.min.css">
    <script type="text/javascript" src="~/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="~/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="~/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="~/static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="~/static/h-ui.admin/js/H-ui.admin.js"></script>
    <script type="text/javascript" src="~/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="~/js/common.js"></script>


    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .minimap {
            position: absolute;
            bottom: 0;
            left: 0;
            z-index: 10000;
            box-shadow: 2px -2px 5px #000;
        }

        html {
            width: 100%;
            height: 100%;
        }

        body {
            width: 100%;
            height: 100%;
            overflow: hidden;
        }


        #mountNode {
            width: 100%;
            height: 100%;
        }

        #header {
            font-family: '楷体';
            padding-top: 10px;
            text-align: center;
        }

        .plc {
            margin: 20px;
        }

        .wcs {
            margin: 20px;
        }

        .Tooltip {
            background: #fff;
            border: 1px solid #ccc;
            padding: 20px;
            border-radius: 20px;
        }

        .btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            position: absolute;
            left: 0;
            top: auto;
        }

            .btn button {
                font-family: '楷体';
                font-weight: bolder;
                width: 100px;
                height: 40px;
                border: 0px;
                border-radius: 1px;
                border-bottom: 4px solid #000;
            }

                .btn button:hover {
                    background: rgb(30, 8, 222);
                    cursor: pointer;
                }


        .ibox {
            display: flex;
            justify-items: center;
        }




        .show {
            display: inline;
            font-weight: bolder;
            color: rgb(30, 8, 222);
        }

        .active {
            background: rgb(30, 8, 222);
            color: #fffe;
        }

        .info > ul > li {
            font-size: 14px;
            margin: 1px;
            list-style: none;
            display: flex;
            font-family: '黑体'
        }

        #LHeader {
            display: inline-block;
            width: 45px;
            height: 45px;
            background: #ccc;
            border-radius: 40px;
            padding: 5px;
            color: #fffe;
        }
    </style>

</head>

<body>
    <input id="signalRUrl" value="@ViewBag.signalRUrl" type="hidden">

    <div id="header">
        <h1><image src="/images/logo.png" height="60px" />   设备实时监控系统 <span id="LHeader">1</span>楼设备  <span style="padding-left:20px">@(Model != null ? Model.UserName : "")</span> <button onclick="showError()" id="error" style="margin-left:20px;border:0px;background:#fff;color:#f00;" class="label radius">报警设备数0个</button></h1>
        <div class="btn">
            <button onclick="changeLayer('4')">线体四层</button>
            <button onclick="changeLayer('3')">线体三层</button>
            <button onclick="changeLayer('2')">线体二层</button>
            <button onclick="changeLayer('1')" class="active">线体一层</button>
            @*<button onclick="changeLayer('1')" class="active">线体一层</button>*@

        </div>
        <div class="tt" style="position:absolute;top:0;right:0;">

            <image src="/images/tp.png" style="height:100vh" />
        </div>
    </div>
    <div id="mountNode"></div>
    <div id="RunString" style="position:absolute;top:100px;left:30vw;text-align:center;font-size:40px;color:red"></div>@*报警跑马灯*@

    <div id="modal-demo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        @*报警弹框*@
        <div class="modal-dialog">
            <div class="modal-content radius">
                <div class="modal-header">
                    <h3 class="modal-title">报警设备</h3>
                    <a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">关闭</a>
                </div>
                <div class="modal-body">
                    <ul id="ErrorInfo" style="list-style-type: none;margin:5px"></ul>
                </div>

            </div>
        </div>
    </div>
    <!-- 平面设备plc wcs数据保存弹窗 -->
    <div class="modal fade" id="plc-wcs-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog modal-lg click-modal" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">修改保存数据</h4>
                </div>
                <div class="modal-body click-div">
                    <iframe id="id_iframe" name="nm_iframe" style="display:none;"></iframe>
                    <div class="click-div-plc">
                        <div class="plc-title-div">
                            <label class="plc-title">PLC</label>
                        </div>
                        <form id="plc-oprator" class="form-horizontal" role="form" target="nm_iframe">
                            <input type="hidden" class="input-text" v-model:value="clickData.plcCurrentData.objectType || 'PlanarGeneralWriteWcsAction'" id="PlcObjectType" style="width:120px">
                            <div class="plc-task-code-div">
                                <label class="label-plc">任务号:</label>
                                <input type="text" class="form-control input-plc-task-code" v-model:value="clickData.plcCurrentData.TaskCode" id="PlcTaskCode" placeholder="任务号" style="width:120px">
                            </div>
                            <div class="plc-action-div">
                                <label class="label-plc">握手类型:</label>
                                <input type="text" class="form-control input-plc-action" v-model:value="clickData.plcCurrentData.ActionType" id="PlcActionType" placeholder="握手类型" style="width:120px">
                            </div>
                            <div class="plc-equipment-div">
                                <label class="label-plc">当前站台:</label>
                                <input type="text" class="form-control input-plc-equipment" v-model:value="clickData.plcCurrentData.EquipmentCode" id="PlcEquipmentCode" placeholder="当前站台" style="width:120px">
                            </div>
                            <div class="plc-toequipment-div">
                                <label class="label-plc">目标站台:</label>
                                <input type="text" class="form-control input-plc-toequipment" v-model:value="clickData.plcCurrentData.ToEquipmentCode" id="PlcToEquipmentCode" placeholder="目标站台" style="width:120px">
                            </div>
                            <div class="plc-palletcode-div">
                                <label class="label-plc">托盘条码:</label>
                                <input type="text" class="form-control input-plc-palletcode" v-model:value="clickData.plcCurrentData.PalletBarcode" id="PlcPalletBarcode" placeholder="托盘条码" style="width:120px">
                            </div>
                            <div class="plc-pallettype-div">
                                <label class="label-plc">托盘类型:</label>
                                <input type="text" class="form-control input-plc-pallettype" v-model:value="clickData.plcCurrentData.PalletType" id="PlcPalletType" placeholder="托盘类型" style="width:120px">
                            </div>
                            <div class="plc-alramcode-div">
                                <label class="label-plc">故障代码:</label>
                                <input type="text" class="form-control input-plc-alramcode" v-model:value="clickData.plcCurrentData.AlrmCode" id="PlcAlrmCode" placeholder="故障代码" style="width:120px">
                            </div>
                            <div class="plc-Reserve-div">
                                <label class="label-plc">备用1:</label>
                                <input type="text" class="form-control input-plc-Reserve" v-model:value="clickData.plcCurrentData.Reserve" id="PlcReserve" placeholder="备用1" style="width:120px">
                            </div>
                            <div class="plc-Reserve2-div">
                                <label class="label-plc">备用2:</label>
                                <input type="text" class="form-control input-plc-Reserve2" v-model:value="clickData.plcCurrentData.Reserve2" id="PlcReserve2" placeholder="备用2" style="width:120px">
                            </div>
                            <div class="plc-Reserve3-div">
                                <label class="label-plc">备用3:</label>
                                <input type="text" class="form-control input-plc-Reserve3" v-model:value="clickData.plcCurrentData.Reserve3" id="PlcReserve3" placeholder="备用3" style="width:120px">
                            </div>
                            <div class="plc-Reserve4-div">
                                <label class="label-plc">备用4:</label>
                                <input type="text" class="form-control input-plc-Reserve4" v-model:value="clickData.plcCurrentData.Reserve4" id="PlcReserve4" placeholder="备用4" style="width:120px">
                            </div>
                        </form>
                    </div>

                    <div class="click-div-wcs">
                        <div class="wcs-title-div">
                            <label class="wcs-title">WCS</label>
                        </div>
                        <form id="wcs-oprator" class="form-horizontal" role="form" target="nm_iframe">
                            <input type="hidden" class="input-text" value="PlanarGeneralWriteWcsAction" id="WcsObjectType">
                            <div class="wcs-task-code-div">
                                <label class="label-wcs">任务号:</label>
                                <input type="text" class="form-control input-wcs-task-code" id="WcsTaskCode" placeholder="任务号" style="width:120px">
                            </div>
                            <div class="wcs-action-div">
                                <label class="label-wcs">握手类型:</label>
                                <input type="text" class="form-control input-wcs-action" id="WcsActionType" placeholder="握手类型" style="width:120px">
                            </div>
                            <div class="wcs-equipment-div">
                                <label class="label-wcs">当前站台:</label>
                                <input type="text" class="form-control input-wcs-equipment" id="WcsEquipmentCode" placeholder="当前站台" style="width:120px">
                            </div>
                            <div class="wcs-toequipment-div">
                                <label class="label-wcs">目标站台:</label>
                                <input type="text" class="form-control input-wcs-toequipment" id="WcsToEquipmentCode" placeholder="目标站台" style="width:120px">
                            </div>
                            <div class="wcs-palletcode-div">
                                <label class="label-wcs">托盘条码:</label>
                                <input type="text" class="form-control input-wcs-palletcode" id="WcsPalletBarcode" placeholder="托盘条码" style="width:120px">
                            </div>
                            <div class="wcs-pallettype-div">
                                <label class="label-wcs">托盘类型:</label>
                                <input type="text" class="form-control input-wcs-pallettype" id="WcsPalletType" placeholder="托盘类型" style="width:120px">
                            </div>
                            <div class="wcs-alramcode-div">
                                <label class="label-wcs">故障代码:</label>
                                <input type="text" class="form-control input-wcs-alramcode" id="WcsAlrmCode" placeholder="故障代码" style="width:120px">
                            </div>
                            <div class="wcs-Reserve-div">
                                <label class="label-wcs">备用1:</label>
                                <input type="text" class="form-control input-wcs-Reserve" id="WcsReserve" placeholder="备用1" style="width:120px">
                            </div>
                            <div class="wcs-Reserve2-div">
                                <label class="label-wcs">备用2:</label>
                                <input type="text" class="form-control input-wcs-Reserve2" id="WcsReserve2" placeholder="备用2" style="width:120px">
                            </div>
                            <div class="wcs-Reserve3-div">
                                <label class="label-wcs">备用3:</label>
                                <input type="text" class="form-control input-wcs-Reserve3" id="WcsReserve3" placeholder="备用3" style="width:120px">
                            </div>
                            <div class="wcs-Reserve4-div">
                                <label class="label-wcs">备用4:</label>
                                <input type="text" class="form-control input-wcs-Reserve4" id="WcsReserve4" placeholder="备用4" style="width:120px">
                            </div>
                        </form>
                    </div>
                </div>
                <div class="modal-footer" style="justify-content:space-around;text-align:center;height:60px">
                    <button type="submit" class="btn btn-info" onclick="operatePlc()" style="margin-left:50px">保存PLC</button>
                    <button type="submit" class="btn btn-info" onclick="operateWcs()" style="margin-left:52%">保存WCS</button>
                </div>
            </div>
        </div>
    </div>


    <!-- 堆垛机设备plc wcs数据保存弹窗 -->
    <div class="modal fade" id="plc-wcs-modal-sc" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog modal-lg click-modal" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">修改保存数据</h4>
                </div>
                <div class="modal-body click-div">
                    <div class="click-div-plc-sc">
                        <div class="plc-title-div-sc">
                            <label class="plc-title">WCS</label>
                        </div>
                        <iframe id="id_iframe-sc" name="nm_iframe-sc" style="display:none;"></iframe>
                        <form id="wcs-oprator-sc" class="form-horizontal" action="" method="post" target="nm_iframe-sc">
                            <input type="hidden" class="input-text" id="objectType">
                            <input type="hidden" class="input-text" id="EquipmentCode">
                            <div class="sc-task-code-div">
                                <label class="label-plc-sc">启动命令:</label>
                                <input type="text" id="Startcommand" class="form-control input-plc-task-code" v-model:value="clickData.wcsCurrentData.Startcommand || false" placeholder="启动命令" style="width:120px">
                            </div>
                            <div class="sc-action-div">
                                <label class="label-plc-sc">报警复位:</label>
                                <input type="text" id="Alarmreset" class="form-control input-plc-action" v-model:value="clickData.wcsCurrentData.Alarmreset || true" placeholder="报警复位" style="width:120px">
                            </div>
                            <div class="sc-equipment-div">
                                <label class="label-plc-sc">WCS消防命令:</label>
                                <input type="text" id="WCSfirecommand" class="form-control input-plc-equipment" v-model:value="clickData.wcsCurrentData.WCSfirecommand || false" placeholder="WCS消防命令" style="width:120px">
                            </div>
                            <div class="sc-toequipment-div">
                                <label class="label-plc-sc">拍照温度无异常:</label>
                                <input type="text" id="WCSPhotoFire" class="form-control input-plc-toequipment" v-model:value="clickData.wcsCurrentData.WCSPhotoFire || false" placeholder="WCS拍照温度无异常" style="width:120px">
                            </div>
                            <div class="sc-palletcode-div">
                                <label class="label-plc-sc">WCS拍照温度异常:</label>
                                <input type="text" id="WCSRgvFireHlper" class="form-control input-plc-palletcode" v-model:value="clickData.wcsCurrentData.WCSRgvFireHlper || false" placeholder="WCS拍照温度异常" style="width:120px">
                            </div>
                            <div class="sc-pallettype-div">
                                <label class="label-plc-sc">有报警无异常:</label>
                                <input type="text" id="WCSDTSAlarm" class="form-control input-plc-pallettype" v-model:value="clickData.wcsCurrentData.WCSDTSAlarm || false" placeholder="有报警无异常" style="width:120px">
                            </div>
                            <div class="sc-alramcode-div">
                                <label class="label-plc-sc">WCS时间复位:</label>
                                <input type="text" id="TimeReset" class="form-control input-plc-alramcode" v-model:value="clickData.wcsCurrentData.TimeReset || false" placeholder="WCS时间复位" style="width:120px">
                            </div>
                            <div class="sc-Reserve-div">
                                <label class="label-plc-sc">WCS过账完成:</label>
                                <input type="text" id="WCSpostingcompleted" class="form-control input-plc-Reserve" v-model:value="clickData.plcCurrentData.WCSpostingcompleted || 0" placeholder="WCS过账完成" style="width:120px">
                            </div>
                            <div class="sc-Reserve2-div">
                                <label class="label-plc-sc">手动任务复位:</label>
                                <input type="text" id="yuliu8" class="form-control input-plc-Reserve2" v-model:value="clickData.wcsCurrentData.yuliu8 || 0" placeholder="手动任务复位" style="width:120px">
                            </div>
                            <div class="sc-Reserve3-div">
                                <label class="label-plc-sc">自动任务复位</label>
                                <input type="text" id="Taskreset" class="form-control input-plc-Reserve3" v-model:value="clickData.wcsCurrentData.Taskreset || false" placeholder="自动任务复位" style="width:120px">
                            </div>
                            <div class="sc-Reserve4-div">
                                <label class="label-plc-sc">备用11:</label>
                                <input type="text" id="yuliu11" class="form-control input-plc-Reserve4" v-model:value="clickData.wcsCurrentData.yuliu11 || 0" placeholder="备用11" style="width:120px">
                            </div>
                            <div class="scwcs-task-code-div">
                                <label class="label-plc-sc">工作序号:</label>
                                <input type="text" id="Jobnumber" class="form-control input-plc-task-code" v-model:value="clickData.wcsCurrentData.Jobnumber || 0" placeholder="工作序号" style="width:120px">
                            </div>
                            <div class="scwcs-action-div">
                                <label class="label-plc-sc">工作命令代码:</label>
                                <input type="text" id="Jobordercode" class="form-control input-plc-action" v-model:value="clickData.wcsCurrentData.Jobordercode || 0" placeholder="工作命令代码" style="width:120px">
                            </div>
                            <div class="scwcs-equipment-div">
                                <label class="label-plc-sc">启始行:</label>
                                <input type="text" id="StartlinefromPC" class="form-control input-plc-equipment" v-model:value="clickData.wcsCurrentData.StartlinefromPC || 0" placeholder="启始行" style="width:120px">
                            </div>
                            <div class="scwcs-toequipment-div">
                                <label class="label-plc-sc">目标行:</label>
                                <input type="text" id="TargetlinefromPC" class="form-control input-plc-toequipment" v-model:value="clickData.wcsCurrentData.TargetlinefromPC || 0" placeholder="目标行" style="width:120px">
                            </div>
                            <div class="scwcs-palletcode-div">
                                <label class="label-plc-sc">启始列:</label>
                                <input type="text" id="StartcolumnfromPC" class="form-control input-plc-palletcode" v-model:value="clickData.wcsCurrentData.StartcolumnfromPC || 0" placeholder="启始列" style="width:120px">
                            </div>
                            <div class="scwcs-pallettype-div">
                                <label class="label-plc-sc">目标列:</label>
                                <input type="text" id="TargetcolumnfromPC" class="form-control input-plc-pallettype" v-model:value="clickData.wcsCurrentData.TargetcolumnfromPC || 0" placeholder="目标列" style="width:120px">
                            </div>
                            <div class="scwcs-alramcode-div">
                                <label class="label-plc-sc">启始层:</label>
                                <input type="text" id="StartlayerfromPC" class="form-control input-plc-alramcode" v-model:value="clickData.wcsCurrentData.StartlayerfromPC || 0" placeholder="启始层" style="width:120px">
                            </div>
                            <div class="scwcs-Reserve-div">
                                <label class="label-plc-sc">目标层:</label>
                                <input type="text" id="TargetlayerfromPC" class="form-control input-plc-Reserve" v-model:value="clickData.wcsCurrentData.TargetlayerfromPC || 0" placeholder="目标层" style="width:120px">
                            </div>
                            <div class="scwcs-Reserve2-div">
                                <label class="label-plc-sc">备用10:</label>
                                <input type="text" id="yuliu10" class="form-control input-plc-Reserve2" v-model:value="clickData.wcsCurrentData.yuliu10 || 0" placeholder="备用10" style="width:120px">
                            </div>
                            <div class="scwcs-Reserve3-div">
                                <label class="label-plc-sc">备用9:</label>
                                <input type="text" id="yuliu9" class="form-control input-plc-Reserve3" v-model:value="clickData.wcsCurrentData.yuliu9 || 0" placeholder="备用9" style="width:120px">
                            </div>
                            <div class="scwcs-Reserve4-div">
                                <label class="label-plc-sc">备用12:</label>
                                <input type="text" id="yuliu12" class="form-control input-plc-Reserve4" v-model:value="clickData.wcsCurrentData.yuliu12 || 0" placeholder="备用12" style="width:120px">
                            </div>
                        </form>
                    </div>
                </div>
                <div class="modal-footer" style="display:flex;align-items:center;text-align:center;flex-direction:row;height:60px;width:100%">
                    <button type="submit" class="btn btn-info" onclick="operateWcsSC()" style="margin-left:47%">保存WCS</button>
                </div>
            </div>
        </div>
    </div>
    <script src="~/js/g6.min.js"></script>
    <script src="../../wwwroot/js/common.js"></script>
    <script>
        var plcData = {}, wcsData = {};

        //处理跳转页面到时候链接signalR 地址改变
        var url;
        url = window.location.href;
        //console.log("url = " + url);

        // 获取到配置中的 signalRURL
        var signalRUrl = $("#signalRUrl").val();
        if (url.indexOf("172.21.224.254") != -1) {
            signalRUrl = signalRUrl.replace("192.168.60.245:8006", "172.21.224.254:8006");
            signalRUrl = signalRUrl.replace("192.168.60.240:8006", "172.21.224.254:10240");
            signalRUrl = signalRUrl.replace("192.168.60.241:8006", "172.21.224.254:10241");
        }
        //创建signalR连接
        var connection = new signalR.HubConnectionBuilder().withUrl(signalRUrl).withAutomaticReconnect([10000, 4000, 10000, 10000]).build();
        connection.serverTimeoutInMilliseconds = 30000;
        const data = {
            currentLayer: 1,
            currentFloor: 'a',
        }

        //提示框
        const tooltip = new G6.Tooltip(
            {
                offsetX: 80,
                offsetY: -80,

                getContent(e) {
                    const outDiv = document.createElement('div');

                    if (e.item.getModel().class == 'line') {


                        if (e.item.getModel().wcsdata == undefined) {

                            outDiv.innerHTML = `
                                                                                             <div class="plc info" style="float:left">
                                                                                                     <h4>plc${e.item.getModel().data.Reserve || e.item.getModel().data.Reserve == 0 ? "" : "(离线)"}</h4>
                                                                                             <ul >
                                                                                              <li>设备编号:<span class="show">${e.item.getModel().station ?? ''}</span></li>
                                                                                               <li>任务号:  <span class="show">${e.item.getModel().data.TaskCode ?? ''}</span></li>
                                                                                               <li>目标设备号:  <span class="show">${e.item.getModel().data.ToEquipmentCode ?? ''}</span></li>
                                                                                               <li>托盘条码:<span class="show">${e.item.getModel().data.PalletBarcode ?? ''}</span></li>
                                                                                               <li>握手类型:<span class="show">${e.item.getModel().data.ActionType ?? ''}</span></li>
                                                                                               <li>托盘类型:<span class="show">${e.item.getModel().data.PalletType ?? ''}</span></li>
                                                                                                <li>单工位手自动:<span class="show">${e.item.getModel().data.Reserve4 == 9 ? "手动" : "自动"}</span></li>
                                                                                                       <li>故障代码:<span class="show">${allPlcAlrmShow(e.item.getModel().data.AlrmCode) ?? ''}</span></li>
                                                                                               <li>预留1:<span class="show">${e.item.getModel().data.Reserve ?? ''}</span></li>
                                                                                               <li>预留2:<span class="show">${e.item.getModel().data.Reserve2 ?? ''}</span></li>
                                                                                               <li>预留3:<span class="show">${e.item.getModel().data.Reserve3 ?? ''}</span></li>
                                                                                               <li>预留4:<span class="show">${e.item.getModel().data.Reserve4 ?? ''}</span></li>

                                                                                                 </div>`
                            return outDiv;
                        }
                        outDiv.innerHTML = `
                                                                                             <div class="plc info" style="float:left">
                                                                                             <h4>plc</h4>
                                                                                             <ul >
                                                                                               <li>设备编号:<span class="show">${e.item.getModel().station ?? '0'}</span></li>
                                                                                               <li>任务号:  <span class="show">${e.item.getModel().data.TaskCode ?? '0'}</span></li>
                                                                                               <li>目标设备号:  <span class="show">${e.item.getModel().data.ToEquipmentCode ?? '0'}</span></li>
                                                                                               <li>托盘条码:<span class="show">${e.item.getModel().data.PalletBarcode ?? '0'}</span></li>
                                                                                               <li>握手类型:<span class="show">${e.item.getModel().data.ActionType ?? '0'}</span></li>
                                                                                               <li>托盘类型:<span class="show">${e.item.getModel().data.PalletType ?? '0'}</span></li>
                                                                                               <li>单工位手自动:<span class="show">${e.item.getModel().data.Reserve4 == 9 ? "手动" : "自动"}</span></li>
                                                                                                       <li>故障代码:<span class="show">${allPlcAlrmShow(e.item.getModel().data.AlrmCode) ?? 0}</span></li>
                                                                                                 <li>预留1:<span class="show">${e.item.getModel().data.Reserve ?? ''}</span></li>
                                                                                               <li>预留2:<span class="show">${e.item.getModel().data.Reserve2 ?? ''}</span></li>
                                                                                               <li>预留3:<span class="show">${e.item.getModel().data.Reserve3 ?? ''}</span></li>
                                                                                               <li>预留4:<span class="show">${e.item.getModel().data.Reserve4 ?? ''}</span></li>
                                                                                             </ul>
                                                                                             </div>
                                                                                             <div class="wcs info" style="float:right">
                                                                                               <h4>wcs</h4>
                                                                                             <ul>
                                                                                              <li>设备编号:<span class="show">${e.item.getModel().station ?? '0'}</span></li>
                                                                                               <li>任务号:  <span class="show">${e.item.getModel().wcsdata.TaskCode ?? '0'}</span></li>
                                                                                               <li>目标设备号:  <span class="show">${e.item.getModel().wcsdata.ToEquipmentCode ?? '0'}</span></li>

                                                                                               <li>托盘条码:<span class="show">${e.item.getModel().wcsdata.PalletBarcode ?? '0'}</span></li>
                                                                                               <li>握手类型:<span class="show">${e.item.getModel().wcsdata.ActionType ?? '0'}</span></li>
                                                                                               <li>托盘类型:<span class="show">${e.item.getModel().wcsdata.PalletType ?? '0'}</span></li>
                                                                                               <li>故障代码:<span class="show">${wcsPlanerAlrmShow(e.item.getModel().wcsdata.AlrmCode) ?? 0}</span></li>
                                                                                               <li>预留1:<span class="show">${e.item.getModel().wcsdata.Reserve ?? '0'}</span></li>
                                                                                               <li>预留2:<span class="show">${e.item.getModel().wcsdata.Reserve2 ?? '0'}</span></li>
                                                                                               <li>预留3:<span class="show">${e.item.getModel().wcsdata.Reserve3 ?? '0'}</span></li>
                                                                                               <li>预留4:<span class="show">${e.item.getModel().wcsdata.Reserve4 ?? '0'}</span></li>

                                                                                             </ul>
                                                                                             </div>
                                                                          `


                    }
                    else if (e.item.getModel().class == 'sc') {
                        outDiv.innerHTML = `<h4 style="text-align:center">堆垛机编号:${e.item.getModel().station}${e.item.getModel().data.Currentline || e.item.getModel().data.Currentline == '0' ? "" : "(离线)"} </h4>
                                                                                              <div class="ibox">
                                                                                              <div class=" info" >

                                                                                             <ul >

                                                                                               <li>堆垛机手自动:  <span class="show">${e.item.getModel().data.StackerHandAutomatic == 1 ? "自动" : "手动"}</span></li>
                                                                                               <li>堆垛机闲忙:    <span class="show">${e.item.getModel().data.StackerBusy == 1 ? "空闲" : "忙"}</span></li>
                                                                                               <li>货叉有盘:      <span class="show">${e.item.getModel().data.Forkhasaterial ? '有' : '无'}</span></li>
                                                                                               <li>堆垛机报警:    <span class="show">${e.item.getModel().data.StackerAlarm ? '是' : '否'}</span></li>
                                                                                               <li>堆垛机运行信号:<span class="show">${e.item.getModel().data.Stackerrunningsignal ? '是' : '否'}</span></li>
                                                                                               <li>堆垛机任务完成:<span class="show">${e.item.getModel().data.StackerTaskCompletion ? '是' : '否'}</span></li>
                                                                                               <li>安全门在线信号:<span class="show">${e.item.getModel().data.SecurityDooronLine ? '是' : '否'}</span></li>
                                                                                               <li>上位机更新状态:<span class="show">${e.item.getModel().data.yuliu1 ? '是' : '否'}</span></li>
                                                                                               <li>请求WSC红外拍照:<span class="show">${e.item.getModel().data.yuliu2 ? '是' : '否'}</span></li>
                                                                                               <li>取料完成:<span class="show">${e.item.getModel().data.yuliu4 ? '是' : '否'}</span></li>
                                                                                               <li>堆垛机报警代码:  <span class="show">${plcAllScAlrmShow(e.item.getModel().data.Stackeralarmcode) ?? e.item.getModel().data.Stackeralarmcode}</span></li>
                                                                                                <li>当前工作序号:  <span class="show">${e.item.getModel().data.Currentjobnumber}</span></li>
                                                                                               <li>当前工作命令代码: <span class="show">${e.item.getModel().data.Currentworkordercode || "当前无工作命令"}</span></li>
                                                                                             </ul>
                                                                                             </div>
                                                                                             <div class="info" >

                                                                                             <ul>

                                                                                               <li>当前行:  <span class="show">${e.item.getModel().data.Currentline}</span></li>
                                                                                               <li>当前列:  <span class="show">${e.item.getModel().data.Currentcolumn}</span></li>
                                                                                               <li>当前层:  <span class="show">${e.item.getModel().data.Currentlayer}</span></li>
                                                                                               <li>启始行: <span class="show"> ${e.item.getModel().data.StartlinetoPC}</span></li>
                                                                                               <li>启始列: <span class="show"> ${e.item.getModel().data.StartcolumntoPC}</span></li>
                                                                                               <li>启始层: <span class="show"> ${e.item.getModel().data.StartlayertoPC}</span></li>
                                                                                               <li>目标行: <span class="show"> ${e.item.getModel().data.TargetlinetoPC}</span></li>
                                                                                               <li>目标列: <span class="show"> ${e.item.getModel().data.TargetcolumntoPC}</span></li>
                                                                                               <li>目标层: <span class="show"> ${e.item.getModel().data.TargetlayertoPC}</span></li>

                                                                                             </ul>
                                                                                             </div>
                                                                                               </div>
                                                                          `
                    }

                    else if (e.item.getModel().class == 'eleLayer') {
                        outDiv.innerHTML = `
                                                                                              <div class="ibox">
                                                                                              <div class=" info" >
                                                                                             <h4 > PLC数据</h4>
                                                                                             <ul >

                                                                                               <li>提升机编号:  <span class="show">${e.item.getModel().station}</span></li>
                                                                                               <li>自动:  <span class="show">${e.item.getModel().data.Auto == 1 ? "自动" : "手动"}</span></li>
                                                                                               <li>繁忙:    <span class="show">${e.item.getModel().data.Busy == 1 ? "繁忙" : "空闲"}</span></li>
                                                                                               <li>上层有盘:      <span class="show">${e.item.getModel().data.UpMaterial == 1 ? "有盘" : "无盘"}</span></li>
                                                                                               <li>下层有盘:    <span class="show">${e.item.getModel().data.DownMaterial == 1 ? "有盘" : "无盘"}</span></li>
                                                                                               <li>任务完成:<span class="show">${e.item.getModel().data.TaskComplete == 1 ? "完成" : "无"}</span></li>
                                                                                               <li>报警:<span class="show">${e.item.getModel().data.LiftAlrm == 1 ? "报警" : "无"}</span></li>
                                                                                               <li>报警代码:<span class="show">${plceleLayerAlrmShow(e.item.getModel().data.LiftAlrmCode) ?? 0}</span></li>
                                                                                               <li>模拟自动:<span class="show">${e.item.getModel().data.Analogautomatic == 1 ? "模拟中" : "无"}</span></li>
                                                                                               <li>当前楼:<span class="show">${e.item.getModel().data.CurrentFloor}</span></li>
                                                                                               <li>当前层:<span class="show">${e.item.getModel().data.CurrentLayer}</span></li>
                                                                                               <li>当前上层功能:<span class="show">${e.item.getModel().data.CurrentUpFunction}</span></li>
                                                                                               <li>当前下层功能:  <span class="show">${e.item.getModel().data.CurrentDownFunction}</span></li>

                                                                                             </ul>
                                                                                             </div>
                                                                                             <div class="info" >
                                                                                             <h4>上层仓位</h4>
                                                                                             <ul>

                                                                                                       <li>上层设备编号:  <span class="show">${e.item.getModel().data.UpEquipmentCode}</span></li>
                                                                                                       <li>上层任务号:  <span class="show">${e.item.getModel().data.UpTaskCode}</span></li>
                                                                                                       <li>上层目标设备号:  <span class="show">${e.item.getModel().data.UpToEquipmentCode}</span></li>
                                                                                                       <li>上层托盘条码: <span class="show"> ${e.item.getModel().data.UpPalletBarcode}</span></li>
                                                                                                       <li>上层握手类型: <span class="show"> ${e.item.getModel().data.UpActionType}</span></li>
                                                                                                       <li>上层托盘类型: <span class="show"> ${e.item.getModel().data.UpPalletType}</span></li>
                                                                                                       <li>上层故障代码: <span class="show"> ${e.item.getModel().data.UpAlrmCode}</span></li>
                                                                                                       <li>上层预留: <span class="show"> ${e.item.getModel().data.UpReserve}</span></li>
                                                                                                       <li>上层预留: <span class="show"> ${e.item.getModel().data.UpReserve2}</span></li>
                                                                                                       <li>上层预留: <span class="show"> ${e.item.getModel().data.UpReserve3}</span></li>
                                                                                                       <li>上层预留: <span class="show"> ${e.item.getModel().data.UpReserve4}</span></li>
                                                                                                     </ul>
                                                                                                     </div>
                                                                                                     <div class="info" >
                                                                                                     <h4>下层仓位</h4>
                                                                                                     <ul>

                                                                                                       <li>下层设备编号:  <span class="show">${e.item.getModel().data.DownEquipmentCode}</span></li>
                                                                                                       <li>下层任务号:  <span class="show">${e.item.getModel().data.DownTaskCode}</span></li>
                                                                                                       <li>下层目标设备号:  <span class="show">${e.item.getModel().data.DownToEquipmentCode}</span></li>
                                                                                                       <li>下层托盘条码: <span class="show"> ${e.item.getModel().data.DownPalletBarcode}</span></li>
                                                                                                       <li>下层握手类型: <span class="show"> ${e.item.getModel().data.DownActionType}</span></li>
                                                                                                       <li>下层托盘类型: <span class="show"> ${e.item.getModel().data.DownPalletType}</span></li>
                                                                                                       <li>下层故障代码: <span class="show"> ${e.item.getModel().data.DownAlrmCode}</span></li>
                                                                                                       <li>下层预留: <span class="show"> ${e.item.getModel().data.DownReserve}</span></li>
                                                                                                       <li>下层预留: <span class="show"> ${e.item.getModel().data.DownReserve2}</span></li>
                                                                                                       <li>下层预留: <span class="show"> ${e.item.getModel().data.DownReserve3}</span></li>
                                                                                                       <li>下层预留: <span class="show"> ${e.item.getModel().data.DownReserve4}</span></li>
                                                                                                     </ul>
                                                                                            </div>
                                                                                       </div>`
                    }
                    else if (e.item.getModel().class == 'rb') {
                        let bd, tq, tc, at, pt, ac;
                        if (e.item.getModel().data == undefined) {
                            bd = 0;
                            tq = 0;
                            tc = 0;
                            at = 0;
                            pt = 0;
                            ac = 0;
                            fx = 0;
                        } else {
                            bd = e.item.getModel().data.PalletBarcode ?? '0';
                            tq = e.item.getModel().data.ToEquipmentCode ?? '0';
                            tc = e.item.getModel().data.TaskCode ?? '0';
                            at = e.item.getModel().data.ActionType ?? '0';
                            pt = e.item.getModel().data.PalletType ?? '0';
                            ac = e.item.getModel().data.AlrmCode ?? '0';
                            fx = e.item.getModel().data.Reserve4 ?? '0';
                        }
                        outDiv.innerHTML = `
                                                                    <div class=" info" style="float:left">
                                                                    <h4>plc</h4>
                                                                    <ul >
                                                                    <li>设备编号:<span class="show">${e.item.getModel().station}</span></li>

                                                                    <li>托盘条码:<span class="show">${bd}</span></li>
                                                                        <li>任务号:  <span class="show">${tc}</span></li>
                                                                    <li>目标设备号:  <span class="show">${tq}</span></li>

                                                                    <li>握手类型:<span class="show">${at}</span></li>
                                                                    <li>托盘类型:<span class="show">${pt}</span></li>
                                                                            <li>故障代码:<span class="show">${allPlcAlrmShow(ac) ?? 0}</span></li>
                                                                    </ul>
                                                                    </div>

                                                `
                    }
                    else if (e.item.getModel().class == 'ocv') {
                        let bd, tq, tc, at, pt, ac, fx;
                        if (e.item.getModel().data == undefined) {
                            bd = 0;
                            tq = 0;
                            tc = 0;
                            at = 0;
                            pt = 0;
                            ac = 0;
                            fx = 0;
                        } else {
                            bd = e.item.getModel().data.PalletBarcode ?? '0';
                            tq = e.item.getModel().data.ToEquipmentCode ?? '0';
                            tc = e.item.getModel().data.TaskCode ?? '0';
                            at = e.item.getModel().data.ActionType ?? '0';
                            pt = e.item.getModel().data.PalletType ?? '0';
                            ac = e.item.getModel().data.AlrmCode ?? '0';
                            fx = e.item.getModel().data.Reserve4 ?? '0';
                        }
                        let bdwcs, tqwcs, tcwcs, atwcs, ptwcs, acwcs, fxwcs;
                        if (e.item.getModel().wcsdata == undefined) {
                            bdwcs = 0;
                            tqwcs = 0;
                            tcwcs = 0;
                            atwcs = 0;
                            ptwcs = 0;
                            acwcs = 0;
                            fxwcs = 0;
                        } else {
                            bdwcs = e.item.getModel().wcsdata.PalletBarcode ?? '0';
                            tqwcs = e.item.getModel().wcsdata.ToEquipmentCode ?? '0';
                            tcwcs = e.item.getModel().wcsdata.TaskCode ?? '0';
                            atwcs = e.item.getModel().wcsdata.ActionType ?? '0';
                            ptwcs = e.item.getModel().wcsdata.PalletType ?? '0';
                            acwcs = e.item.getModel().wcsdata.AlrmCode ?? '0';
                            fxwcs = e.item.getModel().wcsdata.Reserve4 ?? '0'
                        }
                        outDiv.innerHTML = `
                                                                    <div class=" info" style="float:left">
                                                                    <h4>plc</h4>
                                                                    <ul >
                                                                    <li>设备编号:<span class="show">${e.item.getModel().station}</span></li>

                                                                    <li>托盘条码:<span class="show">${bd}</span></li>
                                                                        <li>任务号:  <span class="show">${tc}</span></li>
                                                                    <li>目标设备号:  <span class="show">${tq}</span></li>

                                                                    <li>握手类型:<span class="show">${at}</span></li>
                                                                    <li>托盘类型:<span class="show">${pt}</span></li>
                                                                            <li>故障代码:<span class="show">${allPlcAlrmShow(ac) ?? 0}</span></li>
                                                                    </ul>
                                                                    </div>
                                                                                    <div class="wcs info" style="float:right">
                                                                            <h4>wcs</h4>
                                                                            <ul >
                                                                            <li>设备编号:<span class="show">${e.item.getModel().station}</span></li>

                                                                            <li>托盘条码:<span class="show">${bdwcs}</span></li>
                                                                                <li>任务号:  <span class="show">${tcwcs}</span></li>
                                                                            <li>目标设备号:  <span class="show">${tqwcs}</span></li>

                                                                            <li>握手类型:<span class="show">${atwcs}</span></li>
                                                                            <li>托盘类型:<span class="show">${ptwcs}</span></li>
                                                                            <li>故障代码:<span class="show">${ocvPlcPlanerAlrmShow(acwcs) ?? 0}</span></li>
                                                                            </ul>
                                                                            </div>
                                                `
                    }
                    else if (e.item.getModel().class == 'eleLine') {
                        let bd, tq, tc, at, pt, ac, l1, l2, l3, l4;
                        if (e.item.getModel().data == undefined) {
                            bd = 0;
                            tq = 0;
                            tc = 0;
                            at = 0;
                            pt = 0;
                            ac = 0;
                            l1 = 0;
                            l2 = 0;
                            l3 = 0;
                            l4 = 0;
                        } else {
                            bd = e.item.getModel().data.PalletBarcode ?? '0';
                            tq = e.item.getModel().data.ToEquipmentCode ?? '0';
                            tc = e.item.getModel().data.TaskCode ?? '0';
                            at = e.item.getModel().data.ActionType ?? '0';
                            pt = e.item.getModel().data.PalletType ?? '0';
                            ac = e.item.getModel().data.AlrmCode ?? '0';
                            l1 = e.item.getModel().data.Reserve ?? '0'
                            l2 = e.item.getModel().data.Reserve2 ?? '0'
                            l3 = e.item.getModel().data.Reserve3 ?? '0'
                            l4 = e.item.getModel().data.Reserve4 ?? '0'
                        }
                        let bdwcs, tqwcs, tcwcs, atwcs, ptwcs, acwcs, l1wcs, l2wcs, l3wcs, l4wcs;
                        if (e.item.getModel().wcsdata == undefined) {
                            bdwcs = 0;
                            tqwcs = 0;
                            tcwcs = 0;
                            atwcs = 0;
                            ptwcs = 0;
                            acwcs = 0;
                            l1wcs = 0;
                            l2wcs = 0;
                            l3wcs = 0;
                            l4wcs = 0;
                        } else {
                            bdwcs = e.item.getModel().wcsdata.PalletBarcode ?? '0';
                            tqwcs = e.item.getModel().wcsdata.ToEquipmentCode ?? '0';
                            tcwcs = e.item.getModel().wcsdata.TaskCode ?? '0';
                            atwcs = e.item.getModel().wcsdata.ActionType ?? '0';
                            ptwcs = e.item.getModel().wcsdata.PalletType ?? '0';
                            acwcs = e.item.getModel().wcsdata.AlrmCode ?? '0';
                            l1wcs = e.item.getModel().wcsdata.Reserve ?? '0'
                            l2wcs = e.item.getModel().wcsdata.Reserve2 ?? '0'
                            l3wcs = e.item.getModel().wcsdata.Reserve3 ?? '0'
                            l4wcs = e.item.getModel().wcsdata.Reserve4 ?? '0'
                        }
                        outDiv.innerHTML = `
                                                                                             <div class=" info" style="float:left">
                                                                                             <h4>plc</h4>
                                                                                             <ul >
                                                                                               <li>设备编号:<span class="show">${e.item.getModel().station}</span></li>

                                                                                               <li>托盘条码:<span class="show">${bd}</span></li>
                                                                                                 <li>任务号:  <span class="show">${tc}</span></li>
                                                                                               <li>目标设备号:  <span class="show">${tq}</span></li>

                                                                                               <li>握手类型:<span class="show">${at}</span></li>
                                                                                               <li>托盘类型:<span class="show">${pt}</span></li>
                                                                                                <li>单工位手自动:<span class="show">${l4 == 9 ? "手动" : "自动"}</span></li>
                                                                                                       <li>故障代码:<span class="show">${allPlcAlrmShow(ac) ?? 0}</span></li>
                                                                                               <li>预留1:<span class="show">${l1}</span></li>
                                                                                               <li>预留2:<span class="show">${l2}</span></li>
                                                                                               <li>预留3:<span class="show">${l3}</span></li>
                                                                                               <li>预留4:<span class="show">${l4}</span></li>
                                                                                             </ul>

                                                                                             </div>
                                                                                            <div class="wcs info" style="float:right">
                                                                                            <h4>wcs</h4>
                                                                                            <ul>

                                                                                                <li>设备编号:<span class="show">${e.item.getModel().station}</span></li>

                                                                                                        <li>托盘条码:<span class="show">${bdwcs}</span></li>
                                                                                                            <li>任务号:  <span class="show">${tcwcs}</span></li>
                                                                                                <li>目标设备号:  <span class="show">${tqwcs}</span></li>

                                                                                                <li>握手类型:<span class="show">${atwcs}</span></li>
                                                                                                        <li>托盘类型:<span class="show">${ptwcs}</span></li>
                                                                                                        <li>单工位手自动:<span class="show">${l4wcs == 9 ? "手动" : "自动"}</span></li>
                                                                                                        <li>故障代码:<span class="show">${wcsPlanerAlrmShow(acwcs) ?? 0}</span></li>
                                                                                                        <li>预留1:<span class="show">${l1wcs}</span></li>
                                                                                                        <li>预留2:<span class="show">${l2wcs}</span></li>
                                                                                                        <li>预留3:<span class="show">${l3wcs}</span></li>
                                                                                                        <li>预留4:<span class="show">${l4wcs}</span></li>

                                                                                            </ul>
                                                                                            </div>

                                                                          `
                    }
                    else {
                        outDiv.innerHTML = `
                                                                                                <div class="plc">

                                                                                                        <ul>
                                                                                                          <li>设备编号: ${e.item.getModel().station}</li>
                                                                                                        </ul>
                                                                                                </div>

                                                                                                                                                                                                                                                                              `
                    }


                    return outDiv
                },
                itemTypes: ['node']
            });
        const minimap = new G6.Minimap({
            size: [280, 200],
            className: 'minimap',

            type: 'delegate',

        });
        // 创建 G6 图实例
        const graph = new G6.Graph({
            container: 'mountNode', // 指定图画布的容器 id，与第 9 行的容器对应
            fitView: true,
            fitViewPadding: [50, 50, 100, 50],
            // enabledStack: true,
            // 画布宽高
            width: document.getElementById('mountNode').offsetWidth,
            height: document.getElementById('mountNode').offsetHeight,
            modes: {
                default: ['drag-canvas', 'zoom-canvas'],
            },
            plugins: [tooltip, minimap],
            animate: false,

        });

        $.ajax({
            type: "POST",
            url: "/MonitorEditor/GetMonitorConfigInfoByFloor",
            data: {
                floor: 'a' + '1'
            },
            dataType: "JSON",
            success: function (result) {

                let Data = JSON.parse(result[0].json);

                graph.data(Data)
                graph.render();


                console.log("读取" + 'a' + '1')
                //console.log(Data)

            }
        });
        //-----------------------弹框----------------------\\
        //获取弹框设备号
        $.ajax({
            url: "/plcwritedb/getallplcwritedbinfo",
            type: "POST",

            data: {

                start: 0,
                length: 1000
            },
            dataType: "JSON",
            success: function (result) {
                alertEqu = result.data.map(it => it.equipmentCode)

                console.log("获取弹框设备号")
                // console.log(alertEqu)


            }
        });

        graph.on('node:click', (evt) => {
            let item = evt.item; // 被操作的节点 item
            let station = item.getModel().station
            let type = item.getModel().class

            for (let s of alertEqu) {
                if (s == station) {

                    if (type == 'sc') {
                        $('#plc-wcs-modal-sc').modal();



                        let scitem = item.getModel().wcsdata;
                        if (scitem == undefined) {

                            return;
                        } else {
                            $("#Startcommand").val(scitem.Startcommand)
                            $("#Alarmreset").val(scitem.Alarmreset),
                                $("#WCSfirecommand").val(scitem.WCSfirecommand)
                            $("#WCSPhotoFire").val(scitem.WCSPhotoFire)
                            $("#WCSRgvFireHlper").val(scitem.WCSRgvFireHlper)
                            $("#WCSDTSAlarm").val(scitem.WCSDTSAlarm)
                            $("#TimeReset").val(scitem.TimeReset)
                            $("#WCSpostingcompleted").val(scitem.WCSpostingcompleted)
                            $("#yuliu8").val(scitem.yuliu8),
                                $("#Taskreset").val(scitem.Taskreset)
                            $("#yuliu11").val(scitem.yuliu11)
                            $("#Jobnumber").val(scitem.Jobnumber)
                            $("#Jobordercode").val(scitem.Jobordercode)
                            $("#StartlinefromPC").val(scitem.StartlinefromPC),
                                $("#TargetlinefromPC").val(scitem.TargetlinefromPC),
                                $("#StartcolumnfromPC").val(scitem.StartcolumnfromPC),
                                $("#TargetcolumnfromPC").val(scitem.TargetcolumnfromPC),
                                $("#StartlayerfromPC").val(scitem.StartlayerfromPC),
                                $("#TargetlayerfromPC").val(scitem.TargetlayerfromPC),
                                $("#yuliu10").val(scitem.yuliu10),
                                $("#yuliu9").val(scitem.yuliu9),
                                $("#yuliu12").val(scitem.yuliu12),
                                $("#objectType").val(scitem.ObjectType ?? 'ZJNScMessageWriteWcsActionBO'),
                                $("#EquipmentCode").val(scitem.EquipmentCode)
                        }




                    }
                    else {
                        $('#plc-wcs-modal').modal();
                        let pdata = item.getModel().data;
                        let wdata = item.getModel().wcsdata;


                        if (wdata == undefined) {


                            $("#WcsEquipmentCode").val(item.getModel().station)
                            $("#PlcEquipmentCode").val(item.getModel().station)

                            $("#WcsObjectType").val('PlanarGeneralWriteWcsAction')
                            $("#PlcObjectType").val('PlanarGeneralWriteWcsAction')


                        } else {
                            $("#WcsTaskCode").val(wdata.TaskCode)
                            $("#WcsActionType").val(wdata.ActionType)
                            $("#WcsEquipmentCode").val(wdata.EquipmentCode)
                            $("#WcsToEquipmentCode").val(wdata.ToEquipmentCode)
                            $("#WcsPalletBarcode").val(wdata.PalletBarcode)
                            $("#WcsPalletType").val(wdata.PalletType)
                            $("#WcsAlrmCode").val(wdata.AlrmCode)
                            $("#WcsReserve").val(wdata.Reserve)
                            $("#WcsReserve2").val(wdata.Reserve2)
                            $("#WcsReserve3").val(wdata.Reserve3)
                            $("#WcsReserve4").val(wdata.Reserve4)
                            $("#WcsObjectType").val(wdata.objectType ?? 'PlanarGeneralWriteWcsAction')
                        }
                        //plc
                        if (pdata == undefined) {
                            $("#WcsEquipmentCode").val(item.getModel().station)
                            $("#PlcEquipmentCode").val(item.getModel().station)

                            $("#WcsObjectType").val('PlanarGeneralWriteWcsAction')
                            $("#PlcObjectType").val('PlanarGeneralWriteWcsAction')

                        } else {
                            $("#PlcTaskCode").val(pdata.TaskCode)
                            $("#PlcActionType").val(pdata.ActionType)
                            $("#PlcEquipmentCode").val(pdata.EquipmentCode)
                            $("#PlcToEquipmentCode").val(pdata.ToEquipmentCode)
                            $("#PlcPalletBarcode").val(pdata.PalletBarcode)
                            $("#PlcPalletType").val(pdata.PalletType)
                            $("#PlcAlrmCode").val(pdata.AlrmCode)
                            $("#PlcReserve").val(pdata.Reserve)
                            $("#PlcReserve2").val(pdata.Reserve2)
                            $("#PlcReserve3").val(pdata.Reserve3)
                            $("#PlcReserve4").val(pdata.Reserve4)
                            $("#PlcObjectType").val(pdata.objectType ?? 'PlanarGeneralWriteWcsAction')
                        }



                    }

                    return
                }
            }


        });

        //平面设备保存PLC 写入
        function operatePlc() {
            // alert("平面设备保存PLC 写入")

            var plcBo = {
                TaskCode: $("#PlcTaskCode").val(),
                ActionType: $("#PlcActionType").val(),
                EquipmentCode: $("#PlcEquipmentCode").val(),
                ToEquipmentCode: $("#PlcToEquipmentCode").val(),
                PalletBarcode: $("#PlcPalletBarcode").val(),
                PalletType: $("#PlcPalletType").val(),
                AlrmCode: $("#PlcAlrmCode").val(),
                Reserve: $("#PlcReserve").val(),
                Reserve2: $("#PlcReserve2").val(),
                Reserve3: $("#PlcReserve3").val(),
                Reserve4: $("#PlcReserve4").val(),
                objectType: $("#PlcObjectType").val() ?? 'PlanarGeneralWriteWcsAction'
            };
            SubmitFormForAjax("/monitorfloor2/operateplcbo", plcBo, function (data) {
                if (data.result) {
                    popupAlert('保存成功', 1, function (data) {
                        layer.close(data);
                        popupConfirm("确定关闭窗体吗？", 0, function (data) {
                            $('#plc-wcs-modal').modal('hide');
                            layer.close(data);
                        });
                    });
                } else {
                    popupAlert(data.message, 2, function (data) { layer.close(data); });
                }
            }, true);
        }
        //平面设备保存wcs写入
        function operateWcs() {
            //alert("平面设备保存wcs写入")

            var wcsBo = {
                TaskCode: $("#WcsTaskCode").val(),
                ActionType: $("#WcsActionType").val(),
                EquipmentCode: $("#WcsEquipmentCode").val(),
                ToEquipmentCode: $("#WcsToEquipmentCode").val(),
                PalletBarcode: $("#WcsPalletBarcode").val(),
                PalletType: $("#WcsPalletType").val(),
                AlrmCode: $("#WcsAlrmCode").val(),
                Reserve: $("#WcsReserve").val(),
                Reserve2: $("#WcsReserve2").val(),
                Reserve3: $("#WcsReserve3").val(),
                Reserve4: $("#WcsReserve4").val(),
                objectType: $("#WcsObjectType").val() ?? 'PlanarGeneralWriteWcsAction'
            };
            SubmitFormForAjax("/monitorfloor2/operatewcsbo", wcsBo, function (data) {
                if (data.result) {
                    popupAlert('保存成功', 1, function (data) {
                        layer.close(data);
                        popupConfirm("确定关闭窗体吗？", 0, function (data) {
                            $('#plc-wcs-modal').modal('hide');
                            layer.close(data);
                        });
                    });
                } else {
                    popupAlert(data.message, 2, function (data) { layer.close(data); });
                }
            }, true);
        }
        ///堆垛机保存wcs 写入
        function operateWcsSC() {
            // alert("堆垛机保存wcs 写入")

            var scBO = {
                Startcommand: $("#Startcommand").val() == "true" ? "1" : "0",
                Alarmreset: $("#Alarmreset").val() == "true" ? "1" : "0",
                WCSfirecommand: $("#WCSfirecommand").val() == "true" ? "1" : "0",
                WCSPhotoFire: $("#WCSPhotoFire").val() == "true" ? "1" : "0",
                WCSRgvFireHlper: $("#WCSRgvFireHlper").val() == "true" ? "1" : "0",
                WCSDTSAlarm: $("#WCSDTSAlarm").val() == "true" ? "1" : "0",
                TimeReset: $("#TimeReset").val() == "true" ? "1" : "0",
                WCSpostingcompleted: $("#WCSpostingcompleted").val(),
                yuliu8: $("#yuliu8").val(),
                Taskreset: $("#Taskreset").val() == "true" ? "1" : "0",
                yuliu11: $("#yuliu11").val(),
                Jobnumber: $("#Jobnumber").val(),
                Jobordercode: $("#Jobordercode").val(),
                StartlinefromPC: $("#StartlinefromPC").val(),
                TargetlinefromPC: $("#TargetlinefromPC").val(),
                StartcolumnfromPC: $("#StartcolumnfromPC").val(),
                TargetcolumnfromPC: $("#TargetcolumnfromPC").val(),
                StartlayerfromPC: $("#StartlayerfromPC").val(),
                TargetlayerfromPC: $("#TargetlayerfromPC").val(),
                yuliu10: $("#yuliu10").val(),
                yuliu9: $("#yuliu9").val(),
                yuliu12: $("#yuliu12").val(),
                objectType: $("#objectType").val() ?? 'ZJNScMessageWriteWcsActionBO',
                EquipmentCode: $("#EquipmentCode").val()
            };
            //var dataJson = JSON.stringify(scBO);
            //$("#wcs-oprator-sc").serialize()
            SubmitFormForAjax("/monitorfloor2/operatewcsbo", scBO, function (data) {
                if (data.result) {
                    popupAlert('保存成功', 1, function (data) { layer.close(data); });
                    $('#plc-wcs-modal-sc').modal('hide');
                } else {
                    popupAlert(data.message, 2, function (data) { layer.close(data); });
                }
            }, true);
        }
        //-----------------------弹框end----------------------\\



        function changeLayer(id) {
            data.currentLayer = id;
            event.target.className = 'active'
            for (const a of allSiblings(event.target)) {
                a.className -= 'active'
            }
            //console.log('a' + data.currentLayer)

            $.ajax({
                type: "POST",
                url: "/MonitorEditor/GetMonitorConfigInfoByFloor",
                data: {
                    floor: 'a' + data.currentLayer.toString()
                },
                dataType: "JSON",
                success: function (result) {
                    //console.log(result)
                    if (result.length > 0) {
                        let localData = JSON.parse(result[0].json);



                        // 读取数据
                        if (localData) {
                            graph.changeData(localData, false)
                            //console.log("data_" + data.currentFloor + id + "读取")
                            graph.fitView(150)
                        }
                    }



                }
            });


        }
        var intervalId = -1;
        window.onload = function () {
            //graph.fitView(150);
            console.log(data.currentFloor + "楼层，第" + data.currentLayer + "层线体");
            // 监听服务端发送消息
            connection.on("Floor1CallByHub", function (msg) {
                //console.log("收到服务端消息");
                let serverData = JSON.parse(msg);
                //  console.log(serverData)
                setTimeout(() => {
                    prosServerData(serverData)

                    updateLaxianState(plcData)
                    updateWCS(wcsData)
                    showAlert(plcData, wcsData)
                }, 50)
            });
            //重连之前调用 （只有在掉线的一瞬间，只进入一次）
            connection.onreconnecting(function (error) {
                console.log(connection.state);
                console.log(connection.state === signalR.HubConnectionState.Reconnecting);
                location.reload();
            });
            //(默认4次重连)，任何一次只要回调成功，调用
            connection.onreconnected(function (connectionId) {
                console.log(connectionId);
                console.log(connection.state === signalR.HubConnectionState.Connected);
                document.getElementById("LHeader").style.backgroundColor = '#66c18c';
                // 连接成功后 发送消息调用服务器获取数据方法
                let serverData = JSON.parse(msg);
                //  console.log(serverData)
                setTimeout(() => {
                    prosServerData(serverData)
                    updateLaxianState(plcData)
                    updateWCS(wcsData)
                }, 50)
                getMonitorData();
            });
            //(默认4次重连) 全部都失败后，调用
            // 监听断开连接
            connection.onclose(function () {
                console.log("连接断开")
                document.getElementById("LHeader").style.backgroundColor = '#ccc';
            })
            //开启连接
            connection.start().then(function () {
                console.log("成功！id = " + connection.connectionId);
                document.getElementById("LHeader").style.backgroundColor = '#66c18c';
                // 连接成功后 发送消息调用服务器获取数据方法
                getMonitorData();
            }).catch(function (err) {
                return console.error(err.toString());
            });

        }
        window.onbeforeunload = function () {
            graph.destroy()
            connection.off("Floor1CallByHub");
            connection = null;
            // alert("你关闭了浏览器");

        }

        function getMonitorData() {
            console.log("连接成功开始定时拉取监控数据....");
            clearInterval(intervalId);
            intervalId = setInterval(function () {
                // 连接成功后 发送消息调用服务器获取数据方法
                connection.send("SendFloor1ToClient", connection.connectionId).catch(function (err) {
                    return console.error(err.toString());
                });
            }, 1200);
        }
        //解析数据
        function prosServerData(Data) {
            plcData = {}
            wcsData = {}
            for (let item of Data) {
                // console.log(item);
                //console.log("prosServerData:" + item.ProcessModuleName);

                var equipmentDbObjects = item.equipmentDbObjects;
                if (equipmentDbObjects.length > 0) {
                    for (let dbObj of equipmentDbObjects) {
                        var equipmentCode = dbObj.EquipmentCode;
                        var bytesObjectBases = dbObj.bytesObjectBases;
                        // var bytesObject = {};
                        if (bytesObjectBases.length > 0) {
                            //  bytesObject = bytesObjectBases[0];
                            for (let objBase of bytesObjectBases) {
                                // plc数
                                if (objBase.ObjectType.indexOf("Plc") != -1) {
                                    plcData[equipmentCode] = objBase;
                                } else if (objBase.ObjectType.indexOf("Wcs") != -1) {
                                    //wcs数据
                                    wcsData[equipmentCode] = objBase;
                                } else {//其他不可处理的数据
                                    //console.log("otherObjectType:" + objBase.ObjectType);
                                }
                            }
                        }
                    }
                }
            }


            // console.log("plc", plcData);
            //  console.log("wcs", wcsData);

        }
        //更新wcs 数据
        function updateWCS(mywcsdata) {

            Object.keys(mywcsdata).forEach((k, index) => {
                var wcsItem = mywcsdata[k];



                // console.log("收到数据wcs" + k)
                for (let it of graph.getNodes()) {

                    if (it.getModel().station == k.trim()) {

                        if (it.getModel().class == 'line') {
                            //线体
                            if (it._cfg.states.length === 0) {//plc 不报警
                                if (wcsItem.AlrmCode > 0) {//wcs报警


                                    if (it.getModel().style.fill != '#eea2a4' && `${it.getModel().data.PalletBarcode}`.replaceAll(" ", "") != "") {//为正常颜色设置粉红
                                        graph.setAutoPaint(false);
                                        graph.updateItem(it, {
                                            style: {
                                                fill: "#eea2a4",
                                            }
                                        });
                                        graph.refreshItem(it);
                                        graph.setAutoPaint(true);
                                    }
                                }
                                else {//wcs 不报警


                                    if (it.getModel().style.fill.trim() === '#eea2a4') {//为粉红设置正常颜色
                                        graph.setAutoPaint(false);
                                        graph.updateItem(it, {
                                            style: {
                                                fill: "#66c18c",
                                            }
                                        });
                                        graph.refreshItem(it);
                                        graph.setAutoPaint(true);
                                    }



                                }
                                if (`${it.getModel().data.PalletBarcode}`.replaceAll(" ", "") == "") {
                                    if (it.getModel().style.fill.trim() === '#eea2a4') {//为粉红设置正常颜色
                                        graph.setAutoPaint(false);
                                        graph.updateItem(it, {
                                            style: {
                                                fill: "#66c18c",
                                            }
                                        });
                                        graph.refreshItem(it);
                                        graph.setAutoPaint(true);
                                    }
                                }

                            }


                        } else if (it.getModel().class == 'eleLine') {//eleLine
                            console.log(wcsItem);
                            //判断托盘
                            if (wcsItem.PalletBarcode.replaceAll(" ", "") != "") {

                                if (wcsItem.AlrmCode > 0) {
                                    if (it.getModel().img != '/images/shengjiangji4.png') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/shengjiangji4.png'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }
                                //else if(plcItem.Reserve4 == 9){
                                //    graph.setAutoPaint(false)
                                //    it.update({

                                //        img: '/images/shengjiangji11111.png'
                                //    })
                                //    //  graph.paint();
                                //    graph.refreshItem(it)
                                //    graph.setAutoPaint(true)
                                //}
                                else {
                                    if (it.getModel().img != '/images/shengjiangji2.png') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/shengjiangji2.png'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }


                            }
                            else {
                                if (wcsItem.AlrmCode > 0) {
                                    if (it.getModel().img != '/images/shengjiangji3.png') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/shengjiangji3.png'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }
                                else if (wcsItem.Reserve4 == 9) {
                                    graph.setAutoPaint(false)
                                    it.update({

                                        img: '/images/shengjiangji11111.png'
                                    })
                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                }
                                else {
                                    if (it.getModel().img != '/images/shengjiangji.png') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/shengjiangji.png'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }



                            }
                        }
                        //if(JSON.stringify(it.getModel().wcsdata) != JSON.stringify(wcsItem)){
                        if (isObjEqual(it.getModel().wcsdata, wcsItem) != true) {


                            graph.setAutoPaint(false)

                            it.update({
                                wcsdata: wcsItem,
                            })

                            //graph.refreshItem(it)
                            graph.setAutoPaint(true)
                            // console.log('更新wcs data' + it.getModel().class + it.getModel().station)
                        }




                    }

                }
            })
        }
        //更新plc数据
        function updateLaxianState(mydata) {

            //console.log(mydata)

            Object.keys(mydata).forEach((k, index) => {
                var plcItem = mydata[k]
                //console.log("收到数据" + k)
                for (let it of graph.getNodes()) {


                    if (it.getModel().station == k.trim()) {

                        if (it.getModel().class == 'sc') {
                            //堆垛机

                            //堆垛机报警
                            if (plcItem.StackerAlarm) {
                                if (it.getModel().img.trim() != '/images/duiduoji_hong.png') {
                                    graph.setAutoPaint(false)
                                    it.update({ img: '/images/duiduoji_hong.png' })
                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                    //console.log("更新sc数据" + k)
                                }

                            } else {//没有报警的其他情况
                                //堆垛机手动
                                if (plcItem.StackerHandAutomatic == 0) {
                                    if (it.getModel().img.trim() != '/images/duiduoji_green.png') {
                                        graph.setAutoPaint(false)
                                        it.update({ img: '/images/duiduoji_green.png' })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        //console.log("更新sc数据" + k)
                                    }

                                } else {
                                    //堆垛机忙或者正在运行中
                                    if (plcItem.StackerBusy == 0 || plcItem.Stackerrunningsignal == 1) {
                                        if (it.getModel().img.trim() != '/images/duiduoji_huang.png') {
                                            graph.setAutoPaint(false)
                                            it.update({ img: '/images/duiduoji_huang.png' })
                                            //  graph.paint();
                                            graph.refreshItem(it)
                                            graph.setAutoPaint(true)
                                            //console.log("更新sc数据" + k)
                                        }


                                    } else {   //堆垛机空闲
                                        if (it.getModel().img.trim() != '/images/duiduoji_bai.png') {
                                            graph.setAutoPaint(false)
                                            it.update({ img: '/images/duiduoji_bai.png' })
                                            //  graph.paint();
                                            graph.refreshItem(it)
                                            graph.setAutoPaint(true)
                                            //console.log("更新sc数据" + k)
                                        }



                                    }
                                }
                            }
                        }
                        else if (it.getModel().class == 'line') {
                            //线体



                            //判断线体在线状态
                            if (plcItem.AlrmCode > 0 || plcItem.liftAlrmCode > 0) {
                                if (it._cfg.states.length === 0) {
                                    graph.setAutoPaint(false)
                                    graph.setItemState(it, 'selected', true);
                                    // graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)

                                    //console.log("更新line数据" + k,)

                                }


                            } else {
                                if (it._cfg.states.length !== 0) {
                                    graph.setAutoPaint(false)
                                    graph.setItemState(it, 'selected', false);

                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                    //console.log("更新line数据" + k,)

                                }
                            }


                            //判断单工位手自动状态 9手动  0自动
                            if (plcItem.Reserve4 == 9) {
                                if (it.getModel().style.fill != '#de1c31') {//单工位手动状态且工位未报警时改变颜色(报警则不改变颜色仅在提示框做文字提示)，由正常色改为青色#00FFFF
                                    graph.setAutoPaint(false);
                                    graph.updateItem(it, {
                                        style: {
                                            fill: "#00FFFF",
                                        }
                                    });
                                    graph.refreshItem(it);
                                    graph.setAutoPaint(true);
                                }

                                if (plcItem.AlrmCode == 0) {
                                    if (it.getModel().style.fill.trim() === '#de1c31') {
                                        graph.setAutoPaint(false);
                                        graph.updateItem(it, {
                                            style: {
                                                fill: "#00FFFF",
                                            }
                                        });
                                        graph.refreshItem(it);
                                        graph.setAutoPaint(true);
                                    }

                                }


                                if (plcItem.AlrmCode > 0) {//第二种情况是plc先手动，然后单工位报警要把颜色改为红色报警状态(优先显示报警颜色)
                                    if (it.getModel().style.fill.trim() === '#00FFFF') {
                                        graph.setAutoPaint(false);
                                        graph.updateItem(it, {
                                            style: {
                                                fill: "#de1c31",
                                            }
                                        });
                                        graph.refreshItem(it);
                                        graph.setAutoPaint(true);
                                    }
                                }

                            } else {

                                //console.log("预留4:" + plcItem.Reserve4);
                                if (it.getModel().style.fill.trim() === '#00FFFF') {//为青色改为正常颜色
                                    graph.setAutoPaint(false);
                                    graph.updateItem(it, {
                                        style: {
                                            fill: "#66c18c",
                                        }
                                    });
                                    graph.refreshItem(it);
                                    graph.setAutoPaint(true);
                                }
                                if (plcItem.AlrmCode == 0) {
                                    if (it.getModel().style.fill.trim() === '#de1c31') {//工位未报警，颜色是报警色改为正常色
                                        graph.setAutoPaint(false);
                                        graph.updateItem(it, {
                                            style: {
                                                fill: "#66c18c",
                                            }
                                        });
                                        graph.refreshItem(it);
                                        graph.setAutoPaint(true);
                                    }
                                }
                            }



                            //console.log(k + "  " + plcItem.PalletBarcode)
                            //判断托盘
                            if (plcItem.PalletBarcode.replaceAll(" ", "") != "") {
                                if (it.getModel().stateIcon.show === false) {
                                    graph.setAutoPaint(false)
                                    if (plcItem.AlrmCode > 0 || plcItem.liftAlrmCode > 0) {
                                        graph.updateItem(it, {
                                            stateIcon: {

                                                show: true,
                                                img: '/images/dc_lan.svg'
                                            }
                                        })
                                    } else {
                                        graph.updateItem(it, {

                                            stateIcon: {

                                                show: true,
                                                img: '/images/dc.svg'
                                            }
                                        })
                                    }
                                    //graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                    //console.log("更新line数据" + k,)
                                } else {
                                    if (plcItem.AlrmCode > 0) {
                                        if (it.getModel().stateIcon.img != '/images/dc_lan.svg') {

                                            graph.setAutoPaint(false)
                                            graph.updateItem(it, {
                                                stateIcon: {


                                                    img: '/images/dc_lan.svg'
                                                }
                                            })
                                            graph.refreshItem(it)
                                            graph.setAutoPaint(true)
                                        }
                                    }
                                    else {
                                        if (it.getModel().stateIcon.img != '/images/dc.svg') {
                                            graph.setAutoPaint(false)
                                            graph.updateItem(it, {
                                                stateIcon: {


                                                    img: '/images/dc.svg'
                                                }
                                            })
                                            graph.refreshItem(it)
                                            graph.setAutoPaint(true)

                                        }
                                    }

                                }




                            }
                            else {
                                if (it.getModel().stateIcon.show === true) {
                                    graph.setAutoPaint(false)
                                    graph.updateItem(it, {

                                        stateIcon: {

                                            show: false,
                                        }
                                    })
                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                    //console.log("更新line数据" + k,)
                                }

                            }

                        }
                        else if (it.getModel().class == 'eleLayer') {//提升机

                            // console.log(plcItem);
                            if (plcItem.LiftAlrm == 1) {  //提升机报警

                                if (it.getModel().img.trim() != '/images/loucengtisheng_red.png'.trim()) {
                                    graph.setAutoPaint(false)
                                    it.update({

                                        img: '/images/loucengtisheng_red.png'
                                    })
                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                    //console.log("更新提升机数据" + k)
                                }


                            }
                            else if (plcItem.Busy == 1) {
                                //提升机忙或者正在运行中
                                if (it.getModel().img.trim() != '/images/loucengtisheng_huang.png'.trim()) {
                                    graph.setAutoPaint(false)
                                    it.update({

                                        img: '/images/loucengtisheng_huang.png'
                                    })
                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                    //console.log("更新提升机数据" + k)
                                }





                            }
                            else if (plcItem.Auto == 0) {//提升机手动
                                if (it.getModel().img != '/images/loucengtisheng_green.png') {
                                    graph.setAutoPaint(false)
                                    it.update({

                                        img: '/images/loucengtisheng_green.png'
                                    })
                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                    //console.log("更新提升机数据" + k)
                                }





                            }

                            else {//提升机空闲
                                if (it.getModel().img != '/images/loucengtisheng.png') {
                                    graph.setAutoPaint(false)
                                    it.update({

                                        img: '/images/loucengtisheng.png'
                                    })
                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                    //console.log("更新提升机数据" + k)
                                }





                            }
                        }

                        else if (it.getModel().class == 'rb') {//rb
                            if (plcItem.AlrmCode > 0) {
                                if (it.getModel().img != '/images/rb_bj.svg') {
                                    graph.setAutoPaint(false)
                                    it.update({

                                        img: '/images/rb_bj.svg'
                                    })
                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                    // console.log("更新机械手数据" + k)
                                }
                            } else {
                                //判断托盘
                                if (plcItem.PalletBarcode.replaceAll(" ", "") != "") {
                                    if (it.getModel().img != '/images/rb_tuo.svg') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/rb_tuo.svg'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新机械手数据" + k)
                                    }

                                }
                                else {
                                    if (it.getModel().img != '/images/rb.svg') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/rb.svg'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新机械手数据" + k)
                                    }


                                }
                            }

                        }
                        else if (it.getModel().class == 'ocv') {//ocv

                            //判断托盘
                            if (plcItem.PalletBarcode.replaceAll(" ", "") != "") {
                                if (plcItem.AlrmCode > 0) {
                                    if (it.getModel().img != '/images/ocv2.svg') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/ocv2.svg'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                    }
                                } else {
                                    if (it.getModel().img != '/images/ocv_tuo.svg') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/ocv_tuo.svg'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }

                            }
                            else {
                                if (plcItem.AlrmCode > 0) {
                                    if (it.getModel().img != '/images/ocv2.svg') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/ocv2.svg'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                } else {
                                    if (it.getModel().img != '/images/ocv.svg') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/ocv.svg'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }


                            }
                        } else if (it.getModel().class == 'eleLine') {//eleLine
                            console.log(plcItem);
                            //判断托盘
                            if (plcItem.PalletBarcode.replaceAll(" ", "") != "") {

                                if (plcItem.AlrmCode > 0) {
                                    if (it.getModel().img != '/images/shengjiangji4.png') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/shengjiangji4.png'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }
                                //else if(plcItem.Reserve4 == 9){
                                //    graph.setAutoPaint(false)
                                //    it.update({

                                //        img: '/images/shengjiangji11111.png'
                                //    })
                                //    //  graph.paint();
                                //    graph.refreshItem(it)
                                //    graph.setAutoPaint(true)
                                //}
                                else {
                                    if (it.getModel().img != '/images/shengjiangji2.png') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/shengjiangji2.png'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }


                            }
                            else {
                                if (plcItem.AlrmCode > 0) {
                                    if (it.getModel().img != '/images/shengjiangji3.png') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/shengjiangji3.png'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }
                                else if (plcItem.Reserve4 == 9) {
                                    graph.setAutoPaint(false)
                                    it.update({

                                        img: '/images/shengjiangji11111.png'
                                    })
                                    //  graph.paint();
                                    graph.refreshItem(it)
                                    graph.setAutoPaint(true)
                                }
                                else {
                                    if (it.getModel().img != '/images/shengjiangji.png') {
                                        graph.setAutoPaint(false)
                                        it.update({

                                            img: '/images/shengjiangji.png'
                                        })
                                        //  graph.paint();
                                        graph.refreshItem(it)
                                        graph.setAutoPaint(true)
                                        // console.log("更新ocv数据" + k)
                                    }
                                }



                            }
                        }
                        graph.setAutoPaint(true)
                        //if (JSON.stringify(it.getModel().data) != JSON.stringify(plcItem)) {
                        //  console.log("更新前判断",isObjEqual( it.getModel().data  ,plcItem),it.getModel().class,it.getModel().station)
                        if (isObjEqual(it.getModel().data, plcItem) != true) {

                            graph.setAutoPaint(false)
                            it.update({
                                data: plcItem
                            })
                            //  graph.refreshItem(it)
                            graph.setAutoPaint(true)
                            //console.log('更新plc data' + it.getModel().class + it.getModel().station)
                        }
                        break;

                    }

                }




            }


            )// console.log(mydata)
        }
        //比较2个对象是否相同
        function isObjEqual(x, y) {
            var i, l, leftChain, rightChain;

            function compare2Objects(x, y) {
                var p;

                // remember that NaN === NaN returns false
                // and isNaN(undefined) returns true
                if (isNaN(x) && isNaN(y) && typeof x === 'number' && typeof y === 'number') {
                    return true;
                }

                // Compare primitives and functions.
                // Check if both arguments link to the same object.
                // Especially useful on the step where we compare prototypes
                if (x === y) {
                    return true;
                }

                // Works in case when functions are created in constructor.
                // Comparing dates is a common scenario. Another built-ins?
                // We can even handle functions passed across iframes
                if ((typeof x === 'function' && typeof y === 'function') ||
                    (x instanceof Date && y instanceof Date) ||
                    (x instanceof RegExp && y instanceof RegExp) ||
                    (x instanceof String && y instanceof String) ||
                    (x instanceof Number && y instanceof Number)) {
                    return x.toString() === y.toString();
                }

                // At last checking prototypes as good as we can
                if (!(x instanceof Object && y instanceof Object)) {
                    return false;
                }

                if (x.isPrototypeOf(y) || y.isPrototypeOf(x)) {
                    return false;
                }

                if (x.constructor !== y.constructor) {
                    return false;
                }

                if (x.prototype !== y.prototype) {
                    return false;
                }

                // Check for infinitive linking loops
                if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1) {
                    return false;
                }

                // Quick checking of one object being a subset of another.
                // todo: cache the structure of arguments[0] for performance
                for (p in y) {
                    if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
                        return false;
                    } else if (typeof y[p] !== typeof x[p]) {
                        return false;
                    }
                }

                for (p in x) {
                    if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
                        return false;
                    } else if (typeof y[p] !== typeof x[p]) {
                        return false;
                    }

                    switch (typeof (x[p])) {
                        case 'object':
                        case 'function':

                            leftChain.push(x);
                            rightChain.push(y);

                            if (!compare2Objects(x[p], y[p])) {
                                return false;
                            }

                            leftChain.pop();
                            rightChain.pop();
                            break;

                        default:
                            if (x[p] !== y[p]) {
                                return false;
                            }
                            break;
                    }
                }

                return true;
            }

            if (arguments.length < 1) {
                return true; //Die silently? Don't know how to handle such case, please help...
                // throw "Need two or more arguments to compare";
            }

            for (i = 1, l = arguments.length; i < l; i++) {

                leftChain = []; //Todo: this can be cached
                rightChain = [];

                if (!compare2Objects(arguments[0], arguments[i])) {
                    return false;
                }
            }

            return true;
        }
        function allSiblings(tag) {
            let parent = tag.parentNode;
            let bro = parent.children;
            let siblings = [];
            for (let i = 0; i <= bro.length - 1; i++) {
                if (bro[i] != tag) {
                    siblings.push(bro[i]);
                }
            }
            return siblings;
        }


        function ocvPlcPlanerAlrmShow(id) {
            var alrmCode = id;
            var alrmValue = "0";
            if (parseInt(alrmCode) > 0) {
                //机器人报警
                if (alrmCode == 51) {
                    alrmValue = "机器人夹爪柔性检测异常";
                } else if (alrmCode == 52) {
                    alrmValue = "机器人夹爪探测检测异常";
                } else if (alrmCode == 53) {
                    alrmValue = "机器人夹爪窄边电池检测异常";
                } else if (alrmCode == 54) {
                    alrmValue = "机器人夹爪宽边电池检测异常";
                } else if (alrmCode == 55) {
                    alrmValue = "机器人夹爪窄边夹紧到位异常";
                } else if (alrmCode == 56) {
                    alrmValue = "机器人夹爪窄边张开到位异常";
                } else if (alrmCode == 57) {
                    alrmValue = "机器人夹爪宽边夹紧到位异常";
                } else if (alrmCode == 58) {
                    alrmValue = "机器人夹爪宽边张开到位异常";
                } else if (alrmCode == 59) {
                    alrmValue = "电池类型异常";
                } else if (alrmCode == 60) {
                    alrmValue = "任务号异常";
                } else if (alrmCode == 61) {
                    alrmValue = "位置号异常";
                } else if (alrmCode == 62) {
                    alrmValue = "机器人等待任务超时";
                } else if (alrmCode == 63) {
                    alrmValue = "机器人等待取料超时";
                } else if (alrmCode == 64) {
                    alrmValue = "机器人等待取料完成超时";
                } else if (alrmCode == 65) {
                    alrmValue = "机器人等待放料超时";
                } else if (alrmCode == 66) {
                    alrmValue = "机器人等待放料完成超时";
                } else if (alrmCode == 67) {
                    alrmValue = "取料完成后机器人感应无料";
                } else if (alrmCode == 68) {
                    alrmValue = "取料完成后机器人感应无信息";
                } else if (alrmCode == 69) {
                    alrmValue = "机器人感应电池无信息报警";
                } else if (alrmCode == 70) {
                    alrmValue = "机器人电池有信息无感应报警";
                } else if (alrmCode == 71) {
                    alrmValue = "移动X轴故障";
                } else if (alrmCode == 72) {
                    alrmValue = "移动X轴正极限报警";
                } else if (alrmCode == 73) {
                    alrmValue = "移动X轴负极限报警";
                } else if (alrmCode == 74) {
                    alrmValue = "顶升Y1轴故障";
                } else if (alrmCode == 75) {
                    alrmValue = "顶升Y1轴正极限报警";
                } else if (alrmCode == 76) {
                    alrmValue = "顶升Y1轴负极限报警";
                } else if (alrmCode == 77) {
                    alrmValue = "顶升Y2轴故障";
                } else if (alrmCode == 78) {
                    alrmValue = "顶升Y2轴正极限报警";
                } else if (alrmCode == 79) {
                    alrmValue = "顶升Y2轴负极限报警";
                } else if (alrmCode == 80) {
                    alrmValue = "托盘放反检感应异常";
                } else if (alrmCode == 81) {
                    alrmValue = "MES反馈信息中无电池类型";
                } else if (alrmCode == 82) {
                    alrmValue = "MES提示信息不对,需人工确认";
                } else if (alrmCode == 83) {
                    alrmValue = "托盘条码校验失败报警";
                } else if (alrmCode == 84) {
                    alrmValue = "1#顶升轴回原未完成";
                } else if (alrmCode == 85) {
                    alrmValue = "2#顶升轴回原未完成";
                } else if (alrmCode == 86) {
                    alrmValue = "移动轴回原未完成";
                } else if (alrmCode == 87) {
                    alrmValue = "安全门开报警7";
                } else if (alrmCode == 88) {
                    alrmValue = "安全门急停报警";
                }

                //以下是OCV报警
                else if (alrmCode == 170) {
                    alrmValue = "扫码NG报警";
                }
                else if (alrmCode == 171) {
                    alrmValue = "感应器异常报警";
                }
                else if (alrmCode == 172) {
                    alrmValue = "WCS回复超时";
                }
                else if (alrmCode == 173) {
                    alrmValue = "WCS未回复新目的地址";
                }
                else if (alrmCode == 174) {
                    alrmValue = "入料超时报警";
                }
                else if (alrmCode == 175) {
                    alrmValue = "出料超时报警";
                }
                else if (alrmCode == 176) {
                    alrmValue = "扫码失败报警";
                }
                else if (alrmCode == 177) {
                    alrmValue = "托盘歪斜报警";
                }
                else if (alrmCode == 178) {
                    alrmValue = "托盘条码校验失败";
                }
                else if (alrmCode == 179) {
                    alrmValue = "轴未回原报警";
                }
                else if (alrmCode == 180) {
                    alrmValue = "X轴定位时间过长报警";
                }
                else if (alrmCode == 181) {
                    alrmValue = "Y轴定位时间过长报警";
                }
                else if (alrmCode == 182) {
                    alrmValue = "探针Z轴定位时间过长报警";
                }
                else if (alrmCode == 183) {
                    alrmValue = "NG数量过大，请人工确认";
                }
                else if (alrmCode == 184) {
                    alrmValue = "电池放反报警";
                }
                else if (alrmCode == 185) {
                    alrmValue = "电池内阻无穷大请确认";
                }
                else if (alrmCode == 186) {
                    alrmValue = "OCV检测次数报警";
                }
                else if (alrmCode == 187) {
                    alrmValue = "OCV线体托盘放反报警";
                }
                else if (alrmCode == 188) {
                    alrmValue = "OCV电动滚筒报警";
                }
                else if (alrmCode == 189) {
                    alrmValue = "OCV顶升气缸伸出卡阻报警";
                }
                else if (alrmCode == 190) {
                    alrmValue = "OCV顶升气缸缩回卡阻报警";
                }
                else if (alrmCode == 191) {
                    alrmValue = "OCV顶升气缸检测异常报警";
                }
                else if (alrmCode == 192) {
                    alrmValue = "OCV阻挡气缸伸出卡阻报警";
                }
                else if (alrmCode == 193) {
                    alrmValue = "OCV阻挡气缸缩回卡阻报警";
                }
                else if (alrmCode == 194) {
                    alrmValue = "OCV阻挡气缸检测异常报警";
                }
                else if (alrmCode == 195) {
                    alrmValue = "OCV防反气缸伸出卡阻报警";
                }
                else if (alrmCode == 196) {
                    alrmValue = "OCV防反气缸缩回卡阻报警";
                }
                else if (alrmCode == 197) {
                    alrmValue = "OCV防反气缸检测异常报警";
                }
                else if (alrmCode == 198) {
                    alrmValue = "急停报警";
                }
                else if (alrmCode == 199) {
                    alrmValue = "上位机信息异常报警";
                }
                else if (alrmCode == 200) {
                    alrmValue = "入料超时报警";
                }
                else if (alrmCode == 201) {
                    alrmValue = "出料超时报警";
                }
                else if (alrmCode == 202) {
                    alrmValue = "物流线入料不在自动模式报警";
                }
                else if (alrmCode == 203) {
                    alrmValue = "物流线出料不在自动模式报警";
                }
                else if (alrmCode == 204) {
                    alrmValue = "后门_右上门被打开_I2.4";
                }
                else if (alrmCode == 205) {
                    alrmValue = "后门_左上门被打开_I2.5";
                }
                else if (alrmCode == 206) {
                    alrmValue = "后门_右下门被打开 I2.6";
                }
                else if (alrmCode == 207) {
                    alrmValue = "后门_左下门被打开 I2.7";
                }
                else if (alrmCode == 208) {
                    alrmValue = "前门_左上门被打开 I3.0";
                }
                else if (alrmCode == 209) {
                    alrmValue = "前门_右上门被打开 I3.1";
                }
                else if (alrmCode == 210) {
                    alrmValue = "前门_右下门被打开 I4.0";
                }
                else if (alrmCode == 211) {
                    alrmValue = "前门_左下门被打开 I4.1";
                }
                else if (alrmCode == 212) {
                    alrmValue = "X轴故障报警";
                }
                else if (alrmCode == 213) {
                    alrmValue = "X轴正极限报警故障";
                }
                else if (alrmCode == 214) {
                    alrmValue = "X轴负极限报警故障";
                }
                else if (alrmCode == 215) {
                    alrmValue = "Y轴故障报警";
                }
                else if (alrmCode == 216) {
                    alrmValue = "Y轴正极限报警";
                }
                else if (alrmCode == 217) {
                    alrmValue = "Y轴负极限报警";
                }
                else if (alrmCode == 218) {
                    alrmValue = "探针Z轴故障报警";
                }
                else if (alrmCode == 219) {
                    alrmValue = "探针Z轴正极限报警";
                }
                else if (alrmCode == 220) {
                    alrmValue = "探针Z轴负极限报警";
                }
                else if (alrmCode == 221) {
                    alrmValue = "PC其他异常";
                }
                else if (alrmCode == 222) {
                    alrmValue = "PC请求移动失败";
                }
                else if (alrmCode == 223) {
                    alrmValue = "PC投切板换失败";
                }
                else if (alrmCode == 224) {
                    alrmValue = "PC复位内阻仪失败";
                }
                else if (alrmCode == 225) {
                    alrmValue = "PC内阻清零失败";
                }
                else if (alrmCode == 226) {
                    alrmValue = "PC请求PLC抬起失败";
                }
                else if (alrmCode == 227) {
                    alrmValue = "PC查询配方信息失败";
                }
                else if (alrmCode == 228) {
                    alrmValue = "PC通知PLC完成失败";
                }
                else if (alrmCode == 229) {
                    alrmValue = "PC向WMS上传测试数据失败";
                }
                else if (alrmCode == 230) {
                    alrmValue = "PC向MES上传测试数据失败";
                }
                else if (alrmCode == 231) {
                    alrmValue = "PC保存电芯测试数据失败";
                }
                else if (alrmCode == 232) {
                    alrmValue = "门禁屏蔽开启";
                }
                else if (alrmCode == 233) {
                    alrmValue = "PN掉线报警";
                }
                else if (alrmCode == 234) {
                    alrmValue = "CPU掉线报警";
                }
                else if (alrmCode == 235) {
                    alrmValue = "X轴掉线报警";
                }
                else if (alrmCode == 236) {
                    alrmValue = "Y轴掉线报警";
                }
                else if (alrmCode == 237) {
                    alrmValue = "Z轴掉线报警";
                }
                else if (alrmCode == 238) {
                    alrmValue = "扫码枪掉线报警";
                }
                else if (alrmCode == 239) {
                    alrmValue = "IO模块掉线报警";
                }
                else if (alrmCode == 240) {
                    alrmValue = "PC允许测试超时报警";
                } else {
                    alrmValue = alrmCode;
                }
                return "<font color=\"red\">" + alrmValue + "</font>";
            } else {
                return alrmValue;
            }
        }


        function plcPlanerAlrmShow(id) {
            var alrmCode = id;
            var alrmValue = "0";
            if (parseInt(alrmCode) > 0) {
                if (alrmCode == 1) {
                    alrmValue = "入料超时报警";
                }
                else if (alrmCode == 2) {
                    alrmValue = "到位感应断开异常";
                }
                else if (alrmCode == 3) {
                    alrmValue = "到位感应接通异常";
                }
                else if (alrmCode == 4) {
                    alrmValue = "托盘信息丢失报警(请检查目标编号和条码)";
                }
                else if (alrmCode == 5) {
                    alrmValue = "托盘信息未清除报警(请检查目标编号和条码)";
                }
                else if (alrmCode == 6) {
                    alrmValue = "托盘信息错误报警(检查目标编号是否错误)";
                }
                else if (alrmCode == 7) {
                    alrmValue = "任务申请时托盘条码异常";
                }
                else if (alrmCode == 8) {
                    alrmValue = "WCS响应超时报警";
                }
                else if (alrmCode == 9) {
                    alrmValue = "WCS反馈托盘目的地址错误";
                }
                else if (alrmCode == 10) {
                    alrmValue = "扫码超时报警";
                }
                else if (alrmCode == 11) {
                    alrmValue = "扫码NG报警";
                }
                else if (alrmCode == 12) {
                    alrmValue = "托盘信息错误报警(检查目标编号是否错误)";
                }
                else if (alrmCode == 13) {
                    alrmValue = "入料后无条码报警";
                }
                else if (alrmCode == 14) {
                    alrmValue = "顶升行程开关感应1异常报警";
                }
                else if (alrmCode == 15) {
                    alrmValue = "顶升行程开关感应2异常报警";
                }
                else if (alrmCode == 16) {
                    alrmValue = "托盘条码校验失败报警";
                }
                else if (alrmCode == 17) {
                    alrmValue = "滚筒无料有条码报警";
                }
                else if (alrmCode == 18) {
                    alrmValue = "滚筒有料无条码报警";
                }
                else if (alrmCode == 19) {
                    alrmValue = "货叉感应器断开异常";
                }
                else if (alrmCode == 20) {
                    alrmValue = "急停报警";
                }
                else if (alrmCode == 21) {
                    alrmValue = "顶升气缸伸出卡阻报警";
                }
                else if (alrmCode == 22) {
                    alrmValue = "顶升气缸缩回卡阻报警";
                }
                else if (alrmCode == 23) {
                    alrmValue = "顶升气缸检测异常报警";
                }
                else if (alrmCode == 24) {
                    alrmValue = "直行大阻挡气缸伸出卡阻报警";
                }
                else if (alrmCode == 25) {
                    alrmValue = "直行大阻挡气缸缩回卡阻报警";
                }
                else if (alrmCode == 26) {
                    alrmValue = "直行大阻挡气缸检测异常报警";
                }
                else if (alrmCode == 27) {
                    alrmValue = "直行小阻挡气缸伸出卡阻报警";
                }
                else if (alrmCode == 28) {
                    alrmValue = "直行小阻挡气缸缩回卡阻报警";
                }
                else if (alrmCode == 29) {
                    alrmValue = "直行小阻挡气缸检测异常报警";
                }
                else if (alrmCode == 30) {
                    alrmValue = "左侧大阻挡气缸伸出卡阻报警";
                }
                else if (alrmCode == 31) {
                    alrmValue = "左侧大阻挡气缸缩回卡阻报警";
                }
                else if (alrmCode == 32) {
                    alrmValue = "左侧大阻挡气缸检测异常报警";
                }
                else if (alrmCode == 33) {
                    alrmValue = "左侧小阻挡气缸伸出卡阻报警";
                }
                else if (alrmCode == 34) {
                    alrmValue = "左侧小阻挡气缸缩回卡阻报警";
                }
                else if (alrmCode == 35) {
                    alrmValue = "左侧小阻挡气缸检测异常报警";
                }
                else if (alrmCode == 36) {
                    alrmValue = "右侧大阻挡气缸伸出卡阻报警";
                }
                else if (alrmCode == 37) {
                    alrmValue = "右侧大阻挡气缸缩回卡阻报警";
                }
                else if (alrmCode == 38) {
                    alrmValue = "右侧大阻挡气缸检测异常报警";
                }
                else if (alrmCode == 39) {
                    alrmValue = "右侧小阻挡气缸伸出卡阻报警";
                }
                else if (alrmCode == 40) {
                    alrmValue = "右侧小阻挡气缸缩回卡阻报警";
                }
                else if (alrmCode == 41) {
                    alrmValue = "右侧小阻挡气缸检测异常报警";
                }
                else if (alrmCode == 42) {
                    alrmValue = "线体电动滚筒报警";
                }
                else if (alrmCode == 43) {
                    alrmValue = "移栽电动滚筒报警";
                }
                else if (alrmCode == 44) {
                    alrmValue = "前段入料超时报警";
                }
                else if (alrmCode == 45) {
                    alrmValue = "左段入料超时报警";
                }
                else if (alrmCode == 46) {
                    alrmValue = "右段入料超时报警";
                }
                else if (alrmCode == 47) {
                    alrmValue = "托盘类型异常报警";
                }
                else if (alrmCode == 48) {
                    alrmValue = "托盘放反";
                }
                else if (alrmCode == 49) {
                    alrmValue = "四面条码扫码NG报警";
                }
                else {
                    alrmValue = alrmCode;
                }
                return "<font color=\"red\">" + alrmValue + "</font>";
            } else {
                return alrmValue;
            }
        }
        function wcsPlanerAlrmShow(id) {
            var alrmCode = id;
            var alrmValue = "0";
            if (parseInt(alrmCode) > 0) {
                if (alrmCode == 1) {
                    alrmValue = "PLC托盘码不存在";
                }
                else if (alrmCode == 2) {
                    alrmValue = "投料检验失败";
                }
                else if (alrmCode == 3) {
                    alrmValue = "向Wms请求任务失败";
                }
                else if (alrmCode == 5) {
                    alrmValue = "WCS已下发信息给PLC，PLC无动作，请手动补全信息交互";
                }
                else if (alrmCode == 6) {
                    alrmValue = "此路径没配置";
                }
                else if (alrmCode == 7) {
                    alrmValue = "查看此托盘的任务信息是否正确，PLC是否重复申请";
                }
                else if (alrmCode == 8) {
                    alrmValue = "向WMS申请货位异常";
                }
                else if (alrmCode == 9) {
                    alrmValue = "当前路径不是结束点";
                }
                else if (alrmCode == 10) {
                    alrmValue = "CCD数量校验失败";
                }
                else if (alrmCode == 11) {
                    alrmValue = "托盘校验失败";
                }
                else if (alrmCode == 12) {
                    alrmValue = "空盘校验异常";
                }
                else if (alrmCode == 13) {
                    alrmValue = "解绑失败";
                }
                else if (alrmCode == 14) {
                    alrmValue = "查找不到信息";
                }
                else if (alrmCode == 15) {
                    alrmValue = "此提升机已禁用,此托盘的最后路径是这个提升机。";
                }
                else if (alrmCode == 16) {
                    alrmValue = "等待目标出口无托盘";
                }
                else if (alrmCode == 17) {
                    alrmValue = "此托盘须往前面提升机走才能到达目的地";
                }
                else if (alrmCode == 18) {
                    alrmValue = "此托盘无路可走，请原地等待当前提升机空闲！";
                }
                else if (alrmCode == 19) {
                    alrmValue = "等待入机台无托盘";
                }
                else if (alrmCode == 20) {
                    alrmValue = "WMS没有配置工位信息";
                }
                else if (alrmCode == 21) {
                    alrmValue = "WMS检测NG分选机出口扫码位置流程报错";
                }
                else if (alrmCode == 22) {
                    alrmValue = "WMS检测不存在业务类型数据";
                }
                else if (alrmCode == 23) {
                    alrmValue = "WMS检测扫码位置流程报错";
                }
                else if (alrmCode == 24) {
                    alrmValue = "WMS检测投入口无法查询对应的流程";
                }
                else if (alrmCode == 25) {
                    alrmValue = "WMS检测没有绑定流程参数";
                }
                else if (alrmCode == 26) {
                    alrmValue = "WMS节点数据配置异常";
                }
                else if (alrmCode == 27) {
                    alrmValue = "WMS未配置巷道分配关联数据";
                }
                else if (alrmCode == 28) {
                    alrmValue = "WMS未配置巷道分配关联明细数据";
                }
                else if (alrmCode == 29) {
                    alrmValue = "WMS未配置巷道分组指针";
                }
                else if (alrmCode == 30) {
                    alrmValue = "没有可用巷道";
                }
                else if (alrmCode == 31) {
                    alrmValue = "WMS检测此任务状态不是执行中";
                }
                else if (alrmCode == 32) {
                    alrmValue = "WMS绑定托盘条码与WCS传入托盘条码不符";
                }
                else if (alrmCode == 33) {
                    alrmValue = "WMS没有配置路径数据";
                }
                else if (alrmCode == 34) {
                    alrmValue = "WMS没有配置巷道路径数据";
                }
                else if (alrmCode == 35) {
                    alrmValue = "WMS没有配置托盘数据";
                }
                else if (alrmCode == 36) {
                    alrmValue = "作业托盘号与参数托盘号不一致";
                }
                else if (alrmCode == 37) {
                    alrmValue = "WMS检测作业托盘号不符合条码规则";
                }
                else if (alrmCode == 38) {
                    alrmValue = "WMS作业托盘号绑定的订单不存在";
                }
                else if (alrmCode == 39) {
                    alrmValue = "WMS法找到订单绑定的电池型号";
                }
                else if (alrmCode == 40) {
                    alrmValue = "货位已满";
                }
                else if (alrmCode == 41) {
                    alrmValue = "此托盘未解绑";
                }
                else if (alrmCode == 42) {
                    alrmValue = "等待提升机空闲";
                }
                else if (alrmCode == 43) {
                    alrmValue = "不存在流程配置参数数据";
                }
                else if (alrmCode == 44) {
                    alrmValue = "无托盘数据";
                }
                else if (alrmCode == 45) {
                    alrmValue = " 爆仓流程没有配置货位分组关联数据";
                }
                else if (alrmCode == 47) {
                    alrmValue = "流程节点应为待处理状态！请查看OCV数据是否上传";
                }
                else if (alrmCode == 48) {
                    alrmValue = "流程节点应为待处理状态！请调整对应流程节点状态为待处理状态！";
                }
                else if (alrmCode == 49) {
                    alrmValue = "绑定的流程配置有误！，OCV没测试就排出";
                }
                else if (alrmCode == 50) {
                    alrmValue = "无法获取对应电池类型配置的流程参数";
                }
                else if (alrmCode == 51) {
                    alrmValue = "任务到达上限！";
                }
                else if (alrmCode == 52) {
                    alrmValue = "OCV没有上传数据！";
                }
                else if (alrmCode == 53) {
                    alrmValue = "PLC当前设备号与执行任务当前的目标位置不一致，托盘走错位置或PLC是否重复申请";
                }
                else if (alrmCode == 54) {
                    alrmValue = "请求出环线上报失败！";
                }

                else if (alrmCode == 101) {
                    alrmValue = "PLC线体报警！";
                }
                else if (alrmCode == 102) {
                    alrmValue = "托盘码有误或者不完整！";
                }
                else if (alrmCode == 103) {
                    alrmValue = "托盘已存在任务，请先处理遗留任务！！";
                }
                else if (alrmCode == 104) {
                    alrmValue = "WMS组盘校验失败！请查看接口日志！";
                }
                else if (alrmCode == 105) {
                    alrmValue = "向WMS请求目标位失败！请查看接口日志！";
                }
                else if (alrmCode == 106) {
                    alrmValue = "向WMS请求目标位报错！请查看接口日志！";
                }
                else if (alrmCode == 107) {
                    alrmValue = "向WMS请求任务返回空！请查看接口日志！";
                }
                else if (alrmCode == 108) {
                    alrmValue = "向WMS请求任务工位配置错误！请查看接口日志！";
                }
                else if (alrmCode == 109) {
                    alrmValue = "向WMS请求任务路径配置错误！请查看接口日志！";
                }
                else if (alrmCode == 110) {
                    alrmValue = "向WMS上报称重失败！";
                }
                else if (alrmCode == 111) {
                    alrmValue = "向WMS上报称重报错！";
                }
                else if (alrmCode == 112) {
                    alrmValue = "向WMS请求信息返回失败！请查看接口日志！";
                }
                else if (alrmCode == 113) {
                    alrmValue = "向WMS请求信息返回错误！请查看接口日志！";
                }
                else if (alrmCode == 114) {
                    alrmValue = "WMS任务有误！请检查任务状态！！";
                }
                else if (alrmCode == 115) {
                    alrmValue = "任务错误或者任务路径配置有误！";
                }
                else if (alrmCode == 116) {
                    alrmValue = "托盘当前目标位与任务实际目标位不符！";
                }
                else if (alrmCode == 117) {
                    alrmValue = "入库台请求目标货位失败！请查看接口日志！";
                }
                else if (alrmCode == 118) {
                    alrmValue = "入库台请求目标货位报错！请查看接口日志！";
                }
                else if (alrmCode == 119) {
                    alrmValue = "到达目标位不是任务的终节点！";
                }
                else if (alrmCode == 120) {
                    alrmValue = "到达目标位处理WMS任务失败！请查看接口日志！";
                }
                else if (alrmCode == 121) {
                    alrmValue = "到达目标位处理WMS任务报错！请查看接口日志！";
                }
                else if (alrmCode == 122) {
                    alrmValue = "到达目标位WCS任务状态有误！请查看接口日志！";
                }
                else if (alrmCode == 123) {
                    alrmValue = "到达目标位WCS更新任务失败！请查看接口日志！";
                }
                else if (alrmCode == 124) {
                    alrmValue = "CCD检测校验失败！";
                }
                else if (alrmCode == 125) {
                    alrmValue = "CCD检测校验报错！";
                }
                else if (alrmCode == 126) {
                    alrmValue = "绑盘机获取电池信息失败！请查看接口日志！";
                }
                else if (alrmCode == 127) {
                    alrmValue = "达到分选机上报报错！请查看接口日志！";
                }
                else if (alrmCode == 128) {
                    alrmValue = "到达分选机挑选位上报失败！请查看接口日志！";
                }
                else if (alrmCode == 129) {
                    alrmValue = "分选机上报组盘结果失败！请查看接口日志！";
                }
                else if (alrmCode == 130) {
                    alrmValue = "分选机上报组盘结果时读取DB错误！";
                }
                else if (alrmCode == 131) {
                    alrmValue = "分选机上报组盘结果报错！请查看接口日志！";
                }
                else if (alrmCode == 132) {
                    alrmValue = "分选机挑选位获取挡位信息报错！请查看接口日志！";
                }
                else if (alrmCode == 133) {
                    alrmValue = "分选组盘位上传组盘时挑选单电芯解绑报错！请查看接口日志！";
                }
                else if (alrmCode == 134) {
                    alrmValue = "申请目标位任务已存在，请处理已存在任务！";
                } else {
                    alrmValue = alrmCode;
                }
                return "<font color=\"red\">" + alrmValue + "</font>";
            } else {
                return alrmValue;
            }
        }



        function plceleLayerAlrmShow(id) {
            var alrmCode = id;
            var alrmValue = "0";
            if (parseInt(alrmCode) > 0) {
                if (alrmCode == 1) {
                    alrmValue = "急停报警";
                }
                else if (alrmCode == 2) {
                    alrmValue = "上限位报警";
                }
                else if (alrmCode == 3) {
                    alrmValue = "下限位报警";
                }
                else if (alrmCode == 4) {
                    alrmValue = "上层左限位报警";
                }
                else if (alrmCode == 5) {
                    alrmValue = "上层右限位报警";
                }
                else if (alrmCode == 6) {
                    alrmValue = "下层左限位报警";
                }
                else if (alrmCode == 7) {
                    alrmValue = "下层右限位报警";
                }
                else if (alrmCode == 8) {
                    alrmValue = "变频器错误报警";
                }
                else if (alrmCode == 10) {
                    alrmValue = "WCS楼层信息发送错误报警";
                }
                else if (alrmCode == 11) {
                    alrmValue = "HMI楼层信息发送错误报警";
                }
                else if (alrmCode == 12) {
                    alrmValue = "上层输送电机取料超时报警";
                }
                else if (alrmCode == 12) {
                    alrmValue = "上层输送电机取料超时报警";
                }
                else if (alrmCode == 13) {
                    alrmValue = "下层输送电机取料超时报警";
                }
                else if (alrmCode == 16) {
                    alrmValue = "上层输送电机放料超时报警";
                }
                else if (alrmCode == 17) {
                    alrmValue = "下层输送电机放料超时报警";
                }
                else if (alrmCode == 20) {
                    alrmValue = "定位位置错误报警";
                }
                else if (alrmCode == 21) {
                    alrmValue = "定位到达位置与实际位置不符报警";
                }
                else if (alrmCode == 23) {
                    alrmValue = "提升机运行中托盘撞到上层左极限报警";
                }
                else if (alrmCode == 24) {
                    alrmValue = "提升机运行中托盘撞到上层右极限报警";
                }
                else if (alrmCode == 25) {
                    alrmValue = "提升机运行中托盘撞到下层左极限报警";
                }
                else if (alrmCode == 26) {
                    alrmValue = "提升机运行中托盘撞到下层左极限报警";
                } else {
                    alrmValue = alrmCode;
                }
                return "<font color=\"red\">" + alrmValue + "</font>";
            } else {
                return alrmValue;
            }
        }




        //-----------------刷卡登入----------------------\\

        function LoginIc(code) {
            $.ajax({
                type: "POST",
                url: "/home/UserLoginByIc",
                data: {
                    "ic": code
                },
                success: function (data) {
                    if (data.result) {
                        window.location = "/monitorview/floor1";
                    }
                    else {
                        alert(data.message);
                    }
                }
            });
        }
        var a = ""
        $("body").keydown(function (e) {

            if (a.indexOf("Enter") == -1 && !isNaN(e.key)) {
                // console.log(e.key)
                a += e.key
            }

            if (e.key == "Enter") {
                if (a.length == 10) {
                    console.log("输入：" + a.replace(/[^0-9]/g, ''))
                    LoginIc(a.replace(/[^0-9]/g, ''))
                }


                a = ""

            }
        })
        //----------------------------------------------\\
        //----------------报警弹框-------------------\\
        var lineErrorStations = [];
        var eles = ['410003', '410019', '410029', '410045', '410061', '410071', '410087', '410101', '410113', '410129', '410147', '410163'];
        function showAlert(plcdata, wcsdata) {

            let plc = getKeys(plcdata);
            //let wcs =getKeys(wcsdata);
            for (let it of plc) {
                let item = plcdata[it];

                if (item.AlrmCode > 0 || item.StackerAlarm > 0 || item.LiftAlrm == 1) {
                    if (lineErrorStations.indexOf(it) == -1) {

                        lineErrorStations.push(it)
                    }
                }
                else {
                    if (lineErrorStations.indexOf(it) != -1) {
                        lineErrorStations = lineErrorStations.filter((item) => {
                            return item != it;
                        })
                    }

                }



            }

            render(lineErrorStations)
        }
        function render(Stations) {

            document.getElementById("error").innerHTML = "报警设备数" + Stations.length + "个"


        }
        function showError() {
            document.getElementById("ErrorInfo").innerHTML = ""
            let html = ""
            for (let i of lineErrorStations) {
                if (eles.includes(i))
                    html += `<li style="font-size:20px;margin:6px;text-align:center;">${eles.indexOf(i) + 1}号提升机<span class="label label-success "  style="margin-right:4px">${i}</span>报警</li>`
                else
                    html += `<li style="font-size:20px;margin:6px;text-align:center;">${i[0]}楼 ${i[1]}层<span class="label label-danger " style="margin-right:4px">${i}</span>PLC报警</li>`

            }

            document.getElementById("ErrorInfo").innerHTML = html
            $("#modal-demo").modal("show")


        }
        function getKeys(obj) {
            let keys = []
            for (let p in obj) {
                keys.push(p)
            }
            return keys;
        }

        //跑马灯
        var counter = 0;
        var st = ""
        function f1() {
            if (lineErrorStations.length == 0) {
                document.getElementById("RunString").innerText = "";
                return;
            }
            if (counter == 0 && lineErrorStations.length > 0) {
                for (let i of lineErrorStations) {
                    if (eles.includes(i))
                        st += `${eles.indexOf(i) + 1}号提升机${i}报警` + "\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0"

                    else
                        st += `${i[0]}楼 ${i[1]}层${i}PLC报警` + "\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0"

                }

            }

            //根据ID指定的标签的内容，定义局部变量
            var tag = document.getElementById("RunString");
            //获取标签内部的内容
            var content = st;
            if (content.length <= counter + 39) {
                counter = 0
                return
            }




            let l = content.substring(counter, counter + 40);

            let new_content = l;

            tag.innerText = new_content;
            counter += 1;
        }

        setInterval("f1()", 400) //每0.4秒执行一次定时任务
        //----------------报警弹框End-------------------\\



        //拉取恒翼能状态
        function getHynnstate() {
            $.ajax({
                type: "GET",
                url: "/EquipmentState/HynnEqupmentState",
                data: {

                },
                dataType: "JSON",
                success: function (result) {
                    result.forEach(function (item, index) {
                        // 读取数据
                        //console.log("hynn恒翼能设备号 = " + item.equipmentCode);
                        //console.log("hynn恒翼能设备状态 = " + item.stateCode);
                        if (plcData[item.equipmentCode]) {
                            //console.log("hynn恒翼能设备号 = " + item.equipmentCode + ",hynn恒翼能设备状态 = " + item.stateCode);
                            plcData[item.equipmentCode].HynnAlrmCode = item.stateCode;
                            plcData[item.equipmentCode].AlrmCode = item.stateCode;
                        } else {
                            //console.log("hynn恒翼能设备号 = " + item.equipmentCode + ",hynn恒翼能设备状态 = " + item.stateCode);
                            var bytesObjectBases = {};
                            bytesObjectBases.HynnAlrmCode = item.stateCode;
                            bytesObjectBases.AlrmCode = item.stateCode;
                            bytesObjectBases.PalletBarcode = "";
                            bytesObjectBases.EquipmentCode = item.equipmentCode
                            plcData[item.equipmentCode] = bytesObjectBases;
                        }
                        updateLaxianState(plcData)
                    });
                }
            });
        }
        setInterval("getHynnstate()", 5000) //每0.4秒执行一次定时任务


    </script>

</body>

</html>